in PYTHONPATH not executed


I have a Maya.env file with this line:

…and a file on that path.

In Maya I can see that /Users/myuser/blabla/something/maya has been added just fine - she reads the Maya.env file and appends the path (see below):

import sys

import os

…both of these say that my path is added, but even though this is the case my is not executed at all during Maya startup.

The only thing I have atm in the is some prints and a pymel.core.cube() call. When I start up Maya I see no output in the script editor and no cube is created - my code simply doesn’t run.

What is going on?


Not sure what the problem can be from your description.
But this might help you debug the problem better.

The code that executes all of the files can be edited.
C:\Program Files\Autodesk\Maya2018\Python\Lib\site-packages\maya\app\startup\

from import basic

Adding some prints in there might bring you a step closer to finding the issue.


I migrated the code in to userSetup.mel and it runs just fine now.
There is something odd going on about the Python version of this file - and by odd I mean something regarding Maya’s startup behavior.


One thing to watch out for with userSetup.mel is that Maya only runs the first file with that name that it finds. Whereas it will run all the files that exist on sys.path during startup.

One thing to try when using is wrapping all of your code into a function, and the calling it with maya.utils.executeDeferred(func) as sometimes the fact that is run so much earlier can have an impact on the results of the script.


I also noticed that the file for me printed in the Output Window, and not in the script editor. Took me ages to realise that it was actually picking it up :stuck_out_tongue:


Yeah, this is because at the time that it is being executed the script editor doesn’t actually exist. So stdout hasn’t been redirected to the script editor yet.