I have the following command that I need to run via the subprocess.run()
method in Python3.8:
/home/greg/FreeCAD/FreeCAD-0.20.0-Linux-x86_64.AppImage --console UpdateGeometry.py arg1 arg2 arg3
I’ve implemented this with the following script, evaluate_iteration.py
(I’ve removed fstrings and other boilerplate for simplicity):
import subprocess
def main( paramFile ):
# do stuff
params = readParamFile( paramFile )
make_geometry( params )
# do more stuff
def make_geometry( params ):
subprocess.run( "/home/greg/FreeCAD/FreeCAD-0.20.0-Linux-x86_64.AppImage --console UpdateGeometry.py 20.83 114.9 8.3", shell=True, check=True )
if __name__ == "__main__":
main( sys.argv[-1] )
If I launch Python REPL from the command line and paste the relevant methods from the above script, I can run either main()
or make_geometry()
and the subprocess executes as expected. However, if I run the evaluate_iteration.py
script I get an error:
(conda_deps)greg /path/to/my/cwd $ python3.8 evaluate_iteration.py params_file.csv
Traceback (most recent call last):
File "evaluate_iteration.py", line 94, in <module>
main( paramFile )
File "evaluate_iteration.py", line 14, in main
make_geometry( params )
File "evaluate_iteration.py", line 32, in make_geometry
subprocess.run( "/home/greg/FreeCAD/FreeCAD-0.20.0-Linux-x86_64.AppImage --console UpdateGeometry.py 20.83 114.9 8.3", shell=True, check=True )
File "/my/path/to/conda_deps/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '/home/greg/FreeCAD/FreeCAD-0.20.0-Linux-x86_64.AppImage --console UpdateGeometry.py 20.83 114.9 8.3' returned non-zero exit status 127.
From my experience and Google-fu, the exit status of 127
generally indicates “command not found”… I tried replacing the executable with a different software binary and it works fine. I’ve chmod
-ed the FreeCAD directory to 777
recusively, my cwd to 777
… I’m at a loss for why this isn’t working. Any thoughts?