subprocess a program using another version of python

痴心易碎 提交于 2019-12-24 14:14:32

问题


I am trying to open a maya file in maya from my python application on osx.

The problem seems to be that since maya is also python based, and uses its own version of python, when it tries to open in the environment of my python app, it behaves unreliably (random errors, python script editor stops working, doesn't really open the intended maya file, etc etc).

I have tried:

subprocess.Popen(argList, close_fds = True)
=> maya opens with errors

subprocess.Popen(argList, close_fds = True, shell=True)
=> maya opens with errors

environ = os.environ.copy()
environ["PYTHONPATH"] = ""
subprocess.Popen(argList, close_fds = True, shell=True, env=environ)
=> maya just hangs

environ = os.environ.copy()
environ["PYTHONPATH"] = ""
subprocess.Popen(argList, close_fds = True, shell=False, env=environ)
=> maya just hangs

Interestingly, this happens only on osx. On windows everything works with subprocess.Popen(argList, close_fds = True).

What else can I try? How do I get python to open another program without inheriting the environment, i.e., as if I double clicked on the file?

来源:https://stackoverflow.com/questions/33784665/subprocess-a-program-using-another-version-of-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!