【发布时间】:2023-03-20 21:16:02
【问题描述】:
我想在 Python 中执行一个外部编译程序。在外壳中,
./bin/myProgram ./dir1/arg1 ./dir/arg2 arg3 arg3 arg4
我的 Python 脚本如下所示:
import subprocess
subprocess.call(["./Users/Solar/Desktop/parent/child1/child2/bin/myProgram",
"/Users/Solar/Desktop/parent/child1/child2/dir1/arg1",
"/Users/Solar/Desktop/parent/child1/child2/dir1/arg2",
"arg3", "arg4", "arg5"])
但我收到此错误:
Traceback (most recent call last):
File "/Users/Solar/Desktop/test.py", line 5, in <module>
"32", "0.06", "15"])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Process finished with exit code 1
你能帮帮我吗?提前谢谢你!
【问题讨论】:
-
OSError: [Errno 2] No such file or directory。显然,你的路径是错误的。
标签: python shell subprocess