import subprocess
subprocess.call([path to bat file that run mayapy.exe and execute another python script])
The mayapy script finishes and then I get an error:
Error: Line1: Cannot find procedure “file”
The same happens with os.system(call for mayapy.exe)
The script is working without this error everywhere except one office in another physical location. Could it be related to users’ permissions/rights? Wery weird situation, IDK how to troubleshoot it, looks like the issue is on the OS (Win) side, not with the Python script itself.
Is looks like [path to bat file that run mayapy.exe and execute another python script]
is not at the expected location on the problem machine
so the first thing I would do is look for that .bat file on the local machine
If the .bat file is generated via other scripts, they may be using Environment variables to build the save path for the .bat file ( such as MAYA_PROJECT or something). SO you must use the same logic to build the .bat filepath for your subProcess
One windows Gotcha I have encountered recently:
MS One Drive will hijack your default Documents path.
If you expect C:\Users\username\Documents\maya\...
Some user mayhave One Drive active, making it: C:\Users\username\OneDrive\Documents\maya\
The safest bet in this case is to use the windows HOME env var.
That bat script runs the Python script and it executes fine (the last line of it is a print statement which is working as expected). Something happens when the subprocess is done. Assume “another python script” is print “B”
import subprocess
print “A”
subprocess.call([path to bat file that run mayapy.exe and execute another python script])
print “C”
is the error printing out wrapped in MEL comments? //Error: Line1: Cannot find procedure “file”//
Then we know it’s Maya trying to do something not python
Could be specific to the user’s workspace, as in this issue