Popen错误:[Errno 2]没有这样的文件或目录 [英] Popen error: [Errno 2] No such file or directory
本文介绍了Popen错误:[Errno 2]没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些自定义命令.
# 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]没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文