Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Problem running command line from within Maya2017

Problem running command line from within Maya2017

George.Xyooj
Participant Participant
932 Views
2 Replies
Message 1 of 3

Problem running command line from within Maya2017

George.Xyooj
Participant
Participant

Hopefully this makes sense.  I'm in running Maya2017 and I do have Maya2016 install as well.  I need to run a python script through command line with one argument to process files.

 

    The string that I construct is as follow:  {pythonexe_path} {script_path} {filepath}

 

Running that string manually through command line and the results are as I expected it to be.  The issue is when I try to run it from a custom tool UI within Maya2017.  

 

    The line I use is as follow:  subprocess.Popen( ({pythonexe_path} {script_path} {filepath}) , shell=True)

 

When I run the tool, I get no errors and everything execute except the line mention above.  After some trouble shooting, I have isolated the issue to the {pythonexe_dir} that I'd declared, it points to Maya 2016's mayapy.exe not Maya2017's mayapy.exe.  I tested it by changing the script and the {mayapyexe_path} to Maya2017's and it executes.  

 

Why I'm I using Maya2016->mayapy.exe?  There are some legacy dependencies from 2016 that is still needed.  

 

Does anyone know the reason for this?  Is there work around for this? Or am I going at this the wrong way? 

 

Thanks in advance.

 

 

 

 

0 Likes
933 Views
2 Replies
Replies (2)
Message 2 of 3

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I think you should specify the environment before for popen.

 

e.g.

 

import os
import subprocess

env = {#copied from os.environ in Maya 2016.5}
#It doesn't have 2017 environment variables.
subprocess.Popen("C:/Program Files/Autodesk/Maya2016.5/bin/mayapy.exe e:/ver.py",env = env, shell=False)
#It has 2017 environment variables. subprocess.Popen("C:/Program Files/Autodesk/Maya2016.5/bin/mayapy.exe e:/ver.py", shell=False)

Yours,

Li

 

 

0 Likes
Message 3 of 3

George.Xyooj
Participant
Participant

Thank you kindly.  I'll give that a shot.  

0 Likes