Problems with Python subprocesses from Maya GUI

Problems with Python subprocesses from Maya GUI

Anonymous
Not applicable
1,843 Views
2 Replies
Message 1 of 3

Problems with Python subprocesses from Maya GUI

Anonymous
Not applicable

Hi there!

 

I'm kind of desperate with a weird issue that just appeared suddenly without any particular reason/explanation. I'm pretty sure that this is related to something on our side, but I do not know what it is, where to look at and how to fix this. I double checked with IT and they tell me that nothing changed on their side neither.

 

So, I just hope if you guys could give me just some input that might help me giving some direction to where look into.

 

Here is my problem:

 

It started suddenly, yesterday after lunch time that I'm not able anymore to launch Python instances from within a subprocess launched from Maya in GUI mode.

 

I create a simple executable file that looks like this:

#!/usr/bin/env python
print("Hello World!")

Let's say, I save this file to '/tmp/test' and chmod it to 775 to make it executable.

 

I open Maya, and in the Python script editor, I use following code:

import subprocess
subprocess.call(["/tmp/test"])
# or
# subprocess.call("/tmp/test", shell=True)

And I get following in my terminal:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

When I launch my system python, mayapy or any other software with a Python interpretor and execute the same Python code, I get my expected 'Hello World!' printed in my terminal.

 

Checking a bit internet about this strange error (that I did not see before), people talking about bad Python installations or corrupted virtual environments. But this cannot be the case on my side. I checked multiple Maya versions, and all fail the same way. There is no reason that suddenly, all our Maya installations are broken.

 

I tried as well to set PYTHONHOME to '/usr/bin/python'. In this case, I just get the import error of the 'site' module.

 

I tried as well to launch python in verbosity and got this:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# trying site.so
# trying sitemodule.so
# trying site.py
# trying site.pyc
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/MASH/scripts/site.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/MASH/scripts/sitemodule.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/MASH/scripts/site.py
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/MASH/scripts/site.pyc
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/site.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/sitemodule.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/site.py
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/site.pyc
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/site.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/sitemodule.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/site.py
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/site.pyc
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/site.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/sitemodule.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/site.py
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/camd/scripts/site.pyc
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/substance/scripts/site.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/substance/scripts/sitemodule.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/substance/scripts/site.py
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/substance/scripts/site.pyc
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/xgen/scripts/site.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/xgen/scripts/sitemodule.so
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/xgen/scripts/site.py
# trying /opt/software/thirdparty/autodesk/maya/2018.4/plug-ins/xgen/scripts/site.pyc
ImportError: No module named site

I see that it tries to find the 'site' module. But I can import it in my Maya Python script editor, I can import it in my system python and mayapy.

 

So, if anyone could give me a hint, I would be happy.

 

Thanks for your time!

 

Greets,

Carlo

0 Likes
1,844 Views
2 Replies
Replies (2)
Message 2 of 3

cgiesa
Observer
Observer

Just for the sake of keeping you up-to-date about this subject. We were unable to find out what exactly produced this situation. But we could find a work-around.

 

So, it seemed that somehow, the combination of our system Python installation and Maya did not work together. We started from a clean Python installation on our system and could then run again subprocess out of Maya without any problems.

 

I do not know what 'magic' Maya does that can eventually end up in really crazy behaviours of Python inside subprocesses, but well.

 

This post can be marked as solved.

 

Greets,

Carlo

0 Likes
Message 3 of 3

lee.dunham
Collaborator
Collaborator

I experienced similar issues, and I cant remember whether it was related to PATH variable and conflicting libraries?

0 Likes