Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Setting PYTHONPATH & MAYA_SCRIPT_PATH is preventing Maya from starting properly

mhamid3d
Enthusiast
Enthusiast

Setting PYTHONPATH & MAYA_SCRIPT_PATH is preventing Maya from starting properly

mhamid3d
Enthusiast
Enthusiast

So I'm trying to write a tool for Maya, I've create a directory and in that directory I have a __init__.py, a custom maya launcher bat file, a userSetup.py, and the main directory with all the code.

Like this:

C:/PIPELINE/TOOLS/

- core

--- stuff.py

--- morestuff.py

- __init__.py

- mayaLaunch.bat

- userSetup.py

 

The problem is in my bat file I have set PYTHONPATH & MAYA_SCRIPT_PATH to this directory first, then call maya.exe

set PYTHONPATH=%PYTHONPATH%;C:/PIPELINE/TOOLS

set MAYA_SCRIPT_PATH=%MAYA_SCRIPT_PATH%;C:/PIPELINE/TOOLS

 

When I do this and call maya, it basically says in the output window that it cannot find maya modules, that PYTHONPATH is not set correctly, etc.

Oddly enough when I set the paths one directory down ("core" folder) and run it from there it works perfectly fine.

Does anyone know why this is happening? It's really strange and I can't figure it out for the life of me.

0 Likes
Reply
Accepted solutions (1)
6,465 Views
5 Replies
Replies (5)

olarn
Advocate
Advocate

:thinking_face:

 

- core

--- __init__.py

--- stuff.py

--- morestuff.py

- __init__.py

- mayaLaunch.bat

- userSetup.py

0 Likes

mhamid3d
Enthusiast
Enthusiast

Hey sorry I should've clarified. There is an __init__.py in that folder, and in the main folder but it's besides the problem because it doesn't even make it that far.

Maya crashes before it even detects the userSetup.py file. It has to do with the PYTHONPATH. Something is breaking it and making it so that it overrides all the existing paths, despite adding "%PYTHONPATH%;"

Also the problem does not persist if I set the paths one directory down ("core" folder). Really strange.

Do you know the correct way to temporary add those paths and run maya from command line just for that session?

0 Likes

olarn
Advocate
Advocate

>Maya crashes before it even detects the userSetup.py file.

 

Does the problem persist when you remove all other scripts and plugins and try to load stub version (just empty python file) of python modules in the layout you described?

0 Likes

mhamid3d
Enthusiast
Enthusiast
Accepted solution

I removed all the scripts and just had blanks files. This allowed me to debug the issues, thanks for the suggestion.

Turns out the problem was that it's because I had a folder in my directory called 'maya' and it was overriding the main maya module.

Silly mistake on my part but I do wish I could keep the name maya for that folder.

evanbung
Community Visitor
Community Visitor

Do you know the correct way to temporary add those paths and run maya from command line just for that session?

 

import sys
sys.path.append('my/path/to/module/folder')

 

The better (and more permanent) way to solve this is to set your PYTHONPATH, which provides the interpreter with additional directories look in for python packages/modules.

0 Likes