1

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?

  • Are you giving the path to Maya's python as the first argument of arglist? – stark Nov 18 '15 at 16:06
  • No, the arglist is ["/Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/Maya", "path/to/file.ma"]. Maya is a binary, so cannot be given as an input to maya's python - as far as I know, please correct me if I am wrong. I tried it anyway and it spat out a SyntaxError. – pro-grammar Nov 18 '15 at 18:17
  • 1
    Have you tried ['maya', '-file', 'path/to/file/'] ? You can also pass a snippet of mel to Maya with the -c flag to dump the current environment vars and let you see what the Maya process thinks is going on. – theodox Nov 18 '15 at 19:52
  • Does it work when you just call it from the console? Maybe you need to used `open -a AppName` on OS X. – J. P. Petersen Nov 19 '15 at 08:48
  • It works if I did an open from the terminal, but not if I did a system("open...") from within my python app. – pro-grammar Nov 20 '15 at 18:41
  • Most likely running python has set environment variables. Try running with `env -i`. – stark Nov 21 '15 at 14:32
  • env -i open -a path/to/app path/to/file did it! Thanks stark! – pro-grammar Nov 23 '15 at 14:42
  • accept an answer if it solved the problem. – seanysull Apr 16 '19 at 16:09

0 Answers0