where is does maya source the python scripts from.

1,497 views
Skip to first unread message

jettam

unread,
Sep 8, 2017, 9:05:07 PM9/8/17
to Python Programming for Autodesk Maya
Would someone be able to tell me what file maya is sourcing to find this list. For example if I type "import sys" "sys.path" I get a list of all the folders maya looks in. 

import sys
sys.path
# Result: ['',
 'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\xgen\\scripts\\cafm',
 'C:\\Program Files\\Autodesk\\Maya2017\\bin',
 'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\MASH\\scripts\\MASH',
 'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\bifrost\\scripts\\boss',
 'C:\\solidangle\\mtoadeploy\\2017\\scripts',

Thanks you. 

Justin Israel

unread,
Sep 8, 2017, 9:23:24 PM9/8/17
to Python Programming for Autodesk Maya

Its set by Maya's default environment variables, which can be modified in the Maya.env
https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Environment-Variables-File-path-variables-htm.html

Specifically, the PYTHONHOME dictates the root for the python standard library being injected into the PYTHONPATH


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/126bafad-d182-49d3-b552-36932b6a1646%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Robert White

unread,
Sep 8, 2017, 10:26:34 PM9/8/17
to Python Programming for Autodesk Maya
Also, a fun fact, starting with Maya 2017, the import paths are scrambled during startup by maya.

Basically they are doing:

sys.path = list(set(sys.path) | set(os.environ.get('PYTHONPATH', '').split(os.pathsep)))

The idea is that they are trying to eliminate duplicates, which this does, but because they are putting everything into sets, it scrambles the order.


On Friday, September 8, 2017 at 8:23:24 PM UTC-5, Justin Israel wrote:

Its set by Maya's default environment variables, which can be modified in the Maya.env
https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Environment-Variables-File-path-variables-htm.html

Specifically, the PYTHONHOME dictates the root for the python standard library being injected into the PYTHONPATH


On Sat, Sep 9, 2017, 1:05 PM jettam <justin...@gmail.com> wrote:
Would someone be able to tell me what file maya is sourcing to find this list. For example if I type "import sys" "sys.path" I get a list of all the folders maya looks in. 

import sys
sys.path
# Result: ['',
 'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\xgen\\scripts\\cafm',
 'C:\\Program Files\\Autodesk\\Maya2017\\bin',
 'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\MASH\\scripts\\MASH',
 'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\bifrost\\scripts\\boss',
 'C:\\solidangle\\mtoadeploy\\2017\\scripts',

Thanks you. 

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
Sep 8, 2017, 10:29:11 PM9/8/17
to Python Programming for Autodesk Maya


On Sat, Sep 9, 2017, 2:26 PM Robert White <robert....@gmail.com> wrote:
Also, a fun fact, starting with Maya 2017, the import paths are scrambled during startup by maya.

Basically they are doing:

sys.path = list(set(sys.path) | set(os.environ.get('PYTHONPATH', '').split(os.pathsep)))

The idea is that they are trying to eliminate duplicates, which this does, but because they are putting everything into sets, it scrambles the order.

That is evil. And also very like Autodesk. 



On Friday, September 8, 2017 at 8:23:24 PM UTC-5, Justin Israel wrote:

Its set by Maya's default environment variables, which can be modified in the Maya.env
https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Environment-Variables-File-path-variables-htm.html

Specifically, the PYTHONHOME dictates the root for the python standard library being injected into the PYTHONPATH


On Sat, Sep 9, 2017, 1:05 PM jettam <justin...@gmail.com> wrote:
Would someone be able to tell me what file maya is sourcing to find this list. For example if I type "import sys" "sys.path" I get a list of all the folders maya looks in. 

import sys
sys.path
# Result: ['',
 'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\xgen\\scripts\\cafm',
 'C:\\Program Files\\Autodesk\\Maya2017\\bin',
 'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\MASH\\scripts\\MASH',
 'C:\\Program Files\\Autodesk\\Maya2017\\plug-ins\\bifrost\\scripts\\boss',
 'C:\\solidangle\\mtoadeploy\\2017\\scripts',

Thanks you. 

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e24f62ac-5133-4ccb-8806-049c86b8cc30%40googlegroups.com.

jettam

unread,
Sep 9, 2017, 11:48:08 AM9/9/17
to Python Programming for Autodesk Maya
I am using maya 2017.  Robert mentioned things work differently in maya 2017. I am very new to scripting in Maya and could really do with some help with this question. 

I need to place my python modules in a custom path, and I am confused as to where to put this custom path, so that maya will read it. 

Do I put that custom path into my maya.env folder or into my userSetup.mel.  The maya.env file existed but there is nothing in it!? and the userSetup.met file does not exist, am I suppose to create this one? 


Robert White

unread,
Sep 9, 2017, 12:44:45 PM9/9/17
to Python Programming for Autodesk Maya
Easiest place to places scripts while learning everything is in (if you're on windows) `C:/Users/<you>/documents/maya/2017/scripts`
No clue on other OS's off the top of my head though.

Justin Israel

unread,
Sep 9, 2017, 4:42:08 PM9/9/17
to Python Programming for Autodesk Maya


On Sun, Sep 10, 2017, 4:44 AM Robert White <robert....@gmail.com> wrote:
Easiest place to places scripts while learning everything is in (if you're on windows) `C:/Users/<you>/documents/maya/2017/scripts`
No clue on other OS's off the top of my head though.

Or create a userSetup.py and do something like this for a custom path:

import sys
sys.path.insert(0, "/path/to/custom") 




On Saturday, September 9, 2017 at 10:48:08 AM UTC-5, jettam wrote:
I am using maya 2017.  Robert mentioned things work differently in maya 2017. I am very new to scripting in Maya and could really do with some help with this question. 

I need to place my python modules in a custom path, and I am confused as to where to put this custom path, so that maya will read it. 

Do I put that custom path into my maya.env folder or into my userSetup.mel.  The maya.env file existed but there is nothing in it!? and the userSetup.met file does not exist, am I suppose to create this one? 


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/613ef293-c493-4225-9cfd-0c202b379ad6%40googlegroups.com.

jettam

unread,
Sep 10, 2017, 8:49:40 PM9/10/17
to Python Programming for Autodesk Maya
I made a userSetup.mel file, and placed it here:  C:\Users\justin\Documents\maya\2017\scripts\userSetup.mel    
In this file I added this text: 

import sys
sys.path.insert(0, "E:/ProfessionalDevelopment/python/Introduction to Python Scripting in Maya/cgcircuitPython") 

Should this work? When maya launches will it add this custom path to my sys.path?   I ask because when maya opens I check to see if its there by typing     import sys    and   pprint(sys.path). When I type this I don't see my custom path in the name.

Robert White

unread,
Sep 10, 2017, 8:55:27 PM9/10/17
to Python Programming for Autodesk Maya
Try that with a userSetup.py instead of .mel. Otherwise, yes that should work.

Robert White

unread,
Sep 14, 2017, 8:34:01 PM9/14/17
to Python Programming for Autodesk Maya
So it looks like 2018.1 has potentially fixed this. I've not yet tried the update, but it made it onto the release notes.
Reply all
Reply to author
Forward
0 new messages