我有一些自定义命令.
# works
subprocess.Popen(['python'], stdout=subprocess.PIPE)
但如果我有自己的系统命令,例如 deactivate
,我会收到该错误
But if I have my own system commands like deactivate
, I get that error
Traceback (most recent call last):
File "runner2.py", line 21, in <module>
main()
File "runner2.py", line 18, in main
subprocess.Popen(['deactivate',], stdout=subprocess.PIPE)
File "/usr/lib/python2.6/subprocess.py", line 633, in __init__
errread, errwrite)
File "/usr/lib/python2.6/subprocess.py", line 1139, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
更不用说我需要在我的沙盒 virtualenv 下执行这个了.
Let alone I need to execute this under my sandbox virtualenv.
尝试在 Popen
调用中添加一个额外的参数 shell=True
.
Try add an extra parameter shell=True
to the Popen
call.
这篇关于Popen 错误:[Errno 2] 没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!