Discussion:
[Maya-Python] Maya and PYTHONHOME
Joe Weidenbach
2018-09-01 22:36:34 UTC
Permalink
Hey all,

During a recent bout of programming zealousness, I blew away most of my
previous mess of an environment and set myself to a cleaner package-based
install. Now, I’ve loaded maya for the first time since, and it can’t load
python properly. There was a previous post in here about this for Maya
2013, but this is for 2018, and I’d rather not resurrect a really old
thread.

I’m on windows for this machine, but again I suspect that it’s a more
widespread issue as I have replicated it on Linux.

The package manager (chocolatey) set up python with the PYTHONHOME
environment variable, so now Maya can’t find it’s python libraries.

The stack trace:

Could not find maya.utils._guiExceptHook.
Invalid Python Environment: Python is unable to find Maya's Python modules
Python Environment:
PYTHONHOME = C:\Python27
PYTHONPATH = ;C:/Program Files/Autodesk/Maya2018/plug-ins/ATF/scripts;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts/boss;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts/presets;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/MASH/scripts;d:/Users/joe/Documents/maya/modules/ZivaVFX-Maya-1_2/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/fbx/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/solidangle/mtoadeploy/2018/scripts;C:/ProgramData/Autodesk/ApplicationPlugins/ngskintools/Contents/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/substance/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/cafm;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/xmaya;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/ae;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/brushes;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/dialogs;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/fxmodules;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/tabs;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/util;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/widgets;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts
System modules located at: C:\Program Files\Autodesk\Maya2018\bin\python27.zip
Search path (sys.path):
C:\Program Files\Autodesk\Maya2018\bin
C:\Python27\lib\site-packages\rez-2.0.rc1.39-py2.7.egg
C:\Program Files\Autodesk\Maya2018\bin
C:\Program Files\Autodesk\Maya2018\plug-ins\ATF\scripts
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts\boss
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts\presets
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\MASH\scripts
d:\Users\joe\Documents\maya\modules\ZivaVFX-Maya-1_2\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\fbx\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\camd\scripts
C:\solidangle\mtoadeploy\2018\scripts
C:\ProgramData\Autodesk\ApplicationPlugins\ngskintools\Contents\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\substance\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\cafm
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\xmaya
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\ae
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\brushes
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\dialogs
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\fxmodules
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\tabs
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\util
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\widgets
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts
C:\Program Files\Autodesk\Maya2018\bin\python27.zip
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages

There’s a huge number of these in the output, I expect it’s one per call to
Python.

I’d not expect that unsetting PYTHONHOME is expected/required by autodesk
(although this disproves that theory), as the whole point of shipping
mayapy is to get away from requiring the system install of python (other
benefits include things like being able to use a python compiled with VC15,
allowing the use of PySide2). The question in my mind would be, has anyone
found a way to isolate Maya from the system python environment so it can be
run side by side with other development tools that require PYTHONHOME or
other features like this? I can’t imagine it’s that rare of a need.

Also, I tried to work through this with no luck: Python from an external
interpreter
<https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-83799297-C629-48A8-BCE4-061D3F275215-htm.html>.
It seems that something in 2018 completely breaks using an external
interpreter that could, for example, use virtualenvs to manage dependencies
(this did work as recently as 2016).

Thanks in advance,

Joe
​
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0e7033ed-58d2-487b-accd-7c5e29138483%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Justin Israel
2018-09-01 23:15:05 UTC
Permalink
Post by Joe Weidenbach
Hey all,
During a recent bout of programming zealousness, I blew away most of my
previous mess of an environment and set myself to a cleaner package-based
install. Now, I’ve loaded maya for the first time since, and it can’t load
python properly. There was a previous post in here about this for Maya
2013, but this is for 2018, and I’d rather not resurrect a really old
thread.
I’m on windows for this machine, but again I suspect that it’s a more
widespread issue as I have replicated it on Linux.
The package manager (chocolatey) set up python with the PYTHONHOME
environment variable, so now Maya can’t find it’s python libraries.
Could not find maya.utils._guiExceptHook.
Invalid Python Environment: Python is unable to find Maya's Python modules
PYTHONHOME = C:\Python27
PYTHONPATH = ;C:/Program Files/Autodesk/Maya2018/plug-ins/ATF/scripts;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts/boss;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts/presets;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/MASH/scripts;d:/Users/joe/Documents/maya/modules/ZivaVFX-Maya-1_2/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/fbx/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/solidangle/mtoadeploy/2018/scripts;C:/ProgramData/Autodesk/ApplicationPlugins/ngskintools/Contents/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/substance/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/cafm;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/xmaya;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/ae;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/brushes;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/dialogs;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/fxmodules;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/tabs;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/util;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/widgets;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts
System modules located at: C:\Program Files\Autodesk\Maya2018\bin\python27.zip
C:\Program Files\Autodesk\Maya2018\bin
C:\Python27\lib\site-packages\rez-2.0.rc1.39-py2.7.egg
C:\Program Files\Autodesk\Maya2018\bin
C:\Program Files\Autodesk\Maya2018\plug-ins\ATF\scripts
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts\boss
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts\presets
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\MASH\scripts
d:\Users\joe\Documents\maya\modules\ZivaVFX-Maya-1_2\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\fbx\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\camd\scripts
C:\solidangle\mtoadeploy\2018\scripts
C:\ProgramData\Autodesk\ApplicationPlugins\ngskintools\Contents\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\substance\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\cafm
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\xmaya
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\ae
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\brushes
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\dialogs
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\fxmodules
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\tabs
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\util
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\widgets
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts
C:\Program Files\Autodesk\Maya2018\bin\python27.zip
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages
There’s a huge number of these in the output, I expect it’s one per call
to Python.
I’d not expect that unsetting PYTHONHOME is expected/required by autodesk
(although this disproves that theory), as the whole point of shipping
mayapy is to get away from requiring the system install of python
From reading the docs it seems to be the opposite. Mayapy is shipped to
ensure Maya is correctly bootstrapped for standalone python usage by
providing the correct version of python along with the location of the Maya
libs.


(other benefits include things like being able to use a python compiled
Post by Joe Weidenbach
with VC15, allowing the use of PySide2). The question in my mind would be,
has anyone found a way to isolate Maya from the system python environment
so it can be run side by side with other development tools that require
PYTHONHOME or other features like this?
What happens if you set PYTHONHOME explicitly to Maya's location in the
Maya.env file (similar to what mayapy does)?

I would have expected Maya to always set PYTHONHOME to its internal
location before it initialises its embedded Python interpreter so as to
avoid conflicts with the parent process environment. But that doesn't seem
to be the case if you can break it like this.


I can’t imagine it’s that rare of a need.
Post by Joe Weidenbach
Also, I tried to work through this with no luck: Python from an external
interpreter
<https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-83799297-C629-48A8-BCE4-061D3F275215-htm.html>.
It seems that something in 2018 completely breaks using an external
interpreter that could, for example, use virtualenvs to manage dependencies
(this did work as recently as 2016).
Thanks in advance,
Joe
​
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/0e7033ed-58d2-487b-accd-7c5e29138483%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/0e7033ed-58d2-487b-accd-7c5e29138483%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2Q1XO%2B%2BK0k3z%2Bqvi9xo9_66zQeqVR7EeNE%2BNC25aowWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Joe Weidenbach
2018-09-02 00:41:03 UTC
Permalink
It's interesting, mayapy is an executable on windows as compared to the
script version that comes with linux and OSX. This seems to cause no end
of issues, which is strange because usually windows apps are able to avoid
clashes with the system by bundling libraries locally.

Setting that variable in Maya.env seems to be ignored entirely, as well.

That said, I just tried removing PYTHONHOME from my env so I could query
maya on what it expects (that caused a new error with PYTHONHOME pointing
to one of my user directories, so I'm guessing chocolatey's doing something
funny with the install). When I added the PYTHONHOME var again, pointing
to my default python, maya just started working again. Very strange.
Post by Justin Israel
Post by Joe Weidenbach
Hey all,
During a recent bout of programming zealousness, I blew away most of my
previous mess of an environment and set myself to a cleaner package-based
install. Now, I’ve loaded maya for the first time since, and it can’t load
python properly. There was a previous post in here about this for Maya
2013, but this is for 2018, and I’d rather not resurrect a really old
thread.
I’m on windows for this machine, but again I suspect that it’s a more
widespread issue as I have replicated it on Linux.
The package manager (chocolatey) set up python with the PYTHONHOME
environment variable, so now Maya can’t find it’s python libraries.
Could not find maya.utils._guiExceptHook.
Invalid Python Environment: Python is unable to find Maya's Python modules
PYTHONHOME = C:\Python27
PYTHONPATH = ;C:/Program Files/Autodesk/Maya2018/plug-ins/ATF/scripts;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts/boss;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts/presets;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/MASH/scripts;d:/Users/joe/Documents/maya/modules/ZivaVFX-Maya-1_2/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/fbx/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/solidangle/mtoadeploy/2018/scripts;C:/ProgramData/Autodesk/ApplicationPlugins/ngskintools/Contents/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/substance/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/cafm;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/xmaya;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/ae;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/brushes;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/dialogs;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/fxmodules;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/tabs;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/util;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/widgets;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts
System modules located at: C:\Program Files\Autodesk\Maya2018\bin\python27.zip
C:\Program Files\Autodesk\Maya2018\bin
C:\Python27\lib\site-packages\rez-2.0.rc1.39-py2.7.egg
C:\Program Files\Autodesk\Maya2018\bin
C:\Program Files\Autodesk\Maya2018\plug-ins\ATF\scripts
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts\boss
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts\presets
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\MASH\scripts
d:\Users\joe\Documents\maya\modules\ZivaVFX-Maya-1_2\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\fbx\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\camd\scripts
C:\solidangle\mtoadeploy\2018\scripts
C:\ProgramData\Autodesk\ApplicationPlugins\ngskintools\Contents\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\substance\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\cafm
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\xmaya
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\ae
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\brushes
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\dialogs
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\fxmodules
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\tabs
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\util
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\widgets
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts
C:\Program Files\Autodesk\Maya2018\bin\python27.zip
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages
There’s a huge number of these in the output, I expect it’s one per call
to Python.
I’d not expect that unsetting PYTHONHOME is expected/required by autodesk
(although this disproves that theory), as the whole point of shipping
mayapy is to get away from requiring the system install of python
From reading the docs it seems to be the opposite. Mayapy is shipped to
ensure Maya is correctly bootstrapped for standalone python usage by
providing the correct version of python along with the location of the Maya
libs.
(other benefits include things like being able to use a python compiled
Post by Joe Weidenbach
with VC15, allowing the use of PySide2). The question in my mind would be,
has anyone found a way to isolate Maya from the system python environment
so it can be run side by side with other development tools that require
PYTHONHOME or other features like this?
What happens if you set PYTHONHOME explicitly to Maya's location in the
Maya.env file (similar to what mayapy does)?
I would have expected Maya to always set PYTHONHOME to its internal
location before it initialises its embedded Python interpreter so as to
avoid conflicts with the parent process environment. But that doesn't seem
to be the case if you can break it like this.
I can’t imagine it’s that rare of a need.
Post by Joe Weidenbach
Also, I tried to work through this with no luck: Python from an external
interpreter
<https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-83799297-C629-48A8-BCE4-061D3F275215-htm.html>.
It seems that something in 2018 completely breaks using an external
interpreter that could, for example, use virtualenvs to manage dependencies
(this did work as recently as 2016).
Thanks in advance,
Joe
​
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/0e7033ed-58d2-487b-accd-7c5e29138483%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/0e7033ed-58d2-487b-accd-7c5e29138483%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2Q1XO%2B%2BK0k3z%2Bqvi9xo9_66zQeqVR7EeNE%2BNC25aowWA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2Q1XO%2B%2BK0k3z%2Bqvi9xo9_66zQeqVR7EeNE%2BNC25aowWA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da6zcPKCezPdLhbHxkng2qTNmJXhS5OL1UHA8oO-M2_c1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Joe Weidenbach
2018-09-02 01:27:19 UTC
Permalink
I should clarify, PYTHONHOME in Maya.env is ignored. PYTHONPATH sets just
fine.

Setting the PYTHONPATH in Maya.env gets past the module error, but then
maya can’t find the DLL’s to actually do anything with those modules. It
seems that PYTHONHOME does nasty things for maya.

I’ve been able to work around it by setting up a batch script that unsets
PYTHONHOME and then runs maya, as suggested here
<https://forums.autodesk.com/t5/maya-forum/maya-2015-startup-error-python-conflicting/m-p/5509095>.
Bit of a hack, but it works.
​
Post by Joe Weidenbach
It's interesting, mayapy is an executable on windows as compared to the
script version that comes with linux and OSX. This seems to cause no end
of issues, which is strange because usually windows apps are able to avoid
clashes with the system by bundling libraries locally.
Setting that variable in Maya.env seems to be ignored entirely, as well.
That said, I just tried removing PYTHONHOME from my env so I could query
maya on what it expects (that caused a new error with PYTHONHOME pointing
to one of my user directories, so I'm guessing chocolatey's doing something
funny with the install). When I added the PYTHONHOME var again, pointing
to my default python, maya just started working again. Very strange.
Post by Justin Israel
Post by Joe Weidenbach
Hey all,
During a recent bout of programming zealousness, I blew away most of my
previous mess of an environment and set myself to a cleaner package-based
install. Now, I’ve loaded maya for the first time since, and it can’t load
python properly. There was a previous post in here about this for Maya
2013, but this is for 2018, and I’d rather not resurrect a really old
thread.
I’m on windows for this machine, but again I suspect that it’s a more
widespread issue as I have replicated it on Linux.
The package manager (chocolatey) set up python with the PYTHONHOME
environment variable, so now Maya can’t find it’s python libraries.
Could not find maya.utils._guiExceptHook.
Invalid Python Environment: Python is unable to find Maya's Python modules
PYTHONHOME = C:\Python27
PYTHONPATH = ;C:/Program Files/Autodesk/Maya2018/plug-ins/ATF/scripts;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts/boss;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts/presets;C:/Program Files/Autodesk/Bifrost/Maya2018/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/MASH/scripts;d:/Users/joe/Documents/maya/modules/ZivaVFX-Maya-1_2/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/fbx/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/solidangle/mtoadeploy/2018/scripts;C:/ProgramData/Autodesk/ApplicationPlugins/ngskintools/Contents/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/camd/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/substance/scripts;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/cafm;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/xmaya;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/ae;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/brushes;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/dialogs;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/fxmodules;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/tabs;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/util;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts/xgenm/ui/widgets;C:/Program Files/Autodesk/Maya2018/plug-ins/xgen/scripts
System modules located at: C:\Program Files\Autodesk\Maya2018\bin\python27.zip
C:\Program Files\Autodesk\Maya2018\bin
C:\Python27\lib\site-packages\rez-2.0.rc1.39-py2.7.egg
C:\Program Files\Autodesk\Maya2018\bin
C:\Program Files\Autodesk\Maya2018\plug-ins\ATF\scripts
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts\boss
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts\presets
C:\Program Files\Autodesk\Bifrost\Maya2018\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\MASH\scripts
d:\Users\joe\Documents\maya\modules\ZivaVFX-Maya-1_2\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\fbx\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\camd\scripts
C:\solidangle\mtoadeploy\2018\scripts
C:\ProgramData\Autodesk\ApplicationPlugins\ngskintools\Contents\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\substance\scripts
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\cafm
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\xmaya
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\ae
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\brushes
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\dialogs
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\fxmodules
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\tabs
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\util
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts\xgenm\ui\widgets
C:\Program Files\Autodesk\Maya2018\plug-ins\xgen\scripts
C:\Program Files\Autodesk\Maya2018\bin\python27.zip
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages
There’s a huge number of these in the output, I expect it’s one per call
to Python.
I’d not expect that unsetting PYTHONHOME is expected/required by
autodesk (although this disproves that theory), as the whole point of
shipping mayapy is to get away from requiring the system install of python
From reading the docs it seems to be the opposite. Mayapy is shipped to
ensure Maya is correctly bootstrapped for standalone python usage by
providing the correct version of python along with the location of the Maya
libs.
(other benefits include things like being able to use a python compiled
Post by Joe Weidenbach
with VC15, allowing the use of PySide2). The question in my mind would be,
has anyone found a way to isolate Maya from the system python environment
so it can be run side by side with other development tools that require
PYTHONHOME or other features like this?
What happens if you set PYTHONHOME explicitly to Maya's location in the
Maya.env file (similar to what mayapy does)?
I would have expected Maya to always set PYTHONHOME to its internal
location before it initialises its embedded Python interpreter so as to
avoid conflicts with the parent process environment. But that doesn't seem
to be the case if you can break it like this.
I can’t imagine it’s that rare of a need.
Post by Joe Weidenbach
Also, I tried to work through this with no luck: Python from an
external interpreter
<https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-83799297-C629-48A8-BCE4-061D3F275215-htm.html>.
It seems that something in 2018 completely breaks using an external
interpreter that could, for example, use virtualenvs to manage dependencies
(this did work as recently as 2016).
Thanks in advance,
Joe
​
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/0e7033ed-58d2-487b-accd-7c5e29138483%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/0e7033ed-58d2-487b-accd-7c5e29138483%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2Q1XO%2B%2BK0k3z%2Bqvi9xo9_66zQeqVR7EeNE%2BNC25aowWA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2Q1XO%2B%2BK0k3z%2Bqvi9xo9_66zQeqVR7EeNE%2BNC25aowWA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM33%3Da6XzMcOSeWM1ejGzdCbWw5edP%2Bh43Zu%2BVZvNCykz65cwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...