Python os.system command not working?

2019-08-17 10:13发布

问题:

Earlier I used to code in python well, but after I formatted my computer and reinstalled the same python setup, my os.system command stopped working, as well as subprocess.Popen.

回答1:

Looks like a path issue. The only way I could reproduce that -1 error was by setting my path to nothing so that Python couldn't find cmd.exe.

Here's a link I ran across by searching for "set windows path" in stack exchange:

http://support.microsoft.com/kb/310519

It tells how to set it for Winddows XP, the procedure is pretty much the same in later versions in that you're basically setting up environment variables which are stored in the registry.