- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm having an issue spawning a system Python 2.7 script from the mayapy Python environment. Here is a small example of what I can't get to work. aaa.py uses subprocess to spawn bbb.py.
aaa.py
import subprocess python_path = r'c:\python27\python.exe' callee_path = r'c:\temp\bbb.py' proc_obj = subprocess.Popen([python_path, callee_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = proc_obj.communicate() print('out -> %s' % out.decode()) print('err -> %s' % err.decode())
bbb.py
print('Hello from bbb.py')
If I run the contents of aaa.py inside a Maya script editor, all is well.
If I run this aaa.py using Python 2.7 as the Python env from the shell like this, I get what is expected - "Hello from bbb.py":
C:\>"C:\python27\python.exe" "c:\temp\aaa.py" out -> Hello from bbb.py err ->
However, if I do the same thing, except using mayapy Python environment instead, I get this:
C:\>"C:\Program Files\Autodesk\Maya2016\bin\mayapy.exe" "c:\temp\aaa.py" out -> err -> ImportError: No module named site
I've beat my head, and googled this to death - and then sum. Does anyone have any ideas of what is going on or how to get this to work?
This is an issue on Windows 7, Windows 10, Maya 2016, Maya 2017.
Thanks for reading and cheers,
Paul
Solved! Go to Solution.