Initializing the Maya Python environment

You can use the userSetup.py script to make Maya run specific commands at start up.

userSetup.py runs when Maya is initializing. It will run any Python commands that are in it. It should only include commands that do not depend on Maya's functionality. It can be used to import libraries and add to the system path.

You will need to create userSetup.py yourself and add the commands you want Maya to run on start up, such as importing the maya.cmds module.
Platform userSetup.py location
Linux and macOS $MAYA_APP_DIR/<version>/scripts
Windows %MAYA_APP_DIR%/<version>/scripts
Note: Run getenv("MAYA_APP_DIR") from the Maya Script Editor to get the value of MAYA_APP_DIR. For more information on MAYA_APP_DIR, see File path variables.