I have a script which won't run inside of Nuke's built-in Python interpreter, so I'm trying to launch in via the system's Python instead. I'm using subprocess.Popen to do this, but it still won't run inside a subprocess (missing modules), even though it runs fine at the command prompt (cmd.exe)
I think the problem is, that I just don't understand what environment my subprocess starts up in. It doesn't even run the expected version of Python.
In cmd.exe:
C:/Python27/python.exe -V
> Python 2.7.16
In Nuke:
import subprocess as sub
print sub.Popen("C:/Python27/python.exe -V", stderr=sub.PIPE).communicate()[1]
# Result: Python 2.7.13
print sub.Popen('C:/Python27/python.exe -c
"import sys;print(sys.executable)"',
stdout=sub.PIPE).communicate()[0]
# Result: C:\Python27\python.exe
Where is this lower version of Python coming from? It's probably not a coincidence that Nuke's built-in Python is also 2.7.13, but why would Popen run that and not the .exe I'm specifying?
Note: same result whether I give shell=True or shell=False