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?
2 Answers
Instead ofD:\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.
1 Comment
Maxim Razin
Another major source of the problem is whitespace inside the path. It is much more robust to use a list of parameters instead of a string. Try to do something like Popen(["D:/Program Files/Steam/steamapps/terabytest/sourcesdk/bin/orangebox/bin/vbsp.exe", "param1", "param2"])
echo is not an executable, it's an internal command inside cmd.exe. If you want to use Popen with internal commands, add a keyword parameter shell=True
2 Comments
kettlepot
I put in '"D:\Program Files\Steam\steamapps\terabytest\sourcesdk\bin\orangebox\bin\vbsp.exe"' and I still get errors, it doesn't work with either shell=True or shell=False Why?
tamersalama
try escaping the backslashes (with another backslash)