Popen 给出“文件未找到”错误(Windows/Python)
我试图通过 subprocess.Popen 运行控制台命令,每当我运行它时,即使运行 echo 命令,我也会收到 Windows“文件未找到”错误。 我还在使用 thread 模块创建的线程中使用 Popen。这是问题所在吗?
I'm trying to run console commands via subprocess.Popen, and whenever I run it I get the windows "File not found" error, even when running the echo command.
I am also using Popen inside a thread made with the thread module. Is that the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
D:/Program Files/Steam,而不是
D:\Program Files\Steam\steamapps\terabytes\sourcesdk\bin\orangebox\bin\vbsp.exe
/steamapps/terabytest/sourcesdk/bin/orangebox/bin/vbsp.exe这消除了引号内反斜杠的任何复杂性。
Instead of
D:\Program Files\Steam\steamapps\terabytest\sourcesdk\bin\orangebox\bin\vbsp.exe
, useD:/Program Files/Steam/steamapps/terabytest/sourcesdk/bin/orangebox/bin/vbsp.exe
This eliminates any complications with backslashes inside quotes.
echo
不是可执行文件,它是cmd.exe
内的内部命令。如果您想将 Popen 与内部命令一起使用,请添加关键字参数shell=True
echo
is not an executable, it's an internal command insidecmd.exe
. If you want to use Popen with internal commands, add a keyword parametershell=True