2

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.

enter image description here

8
  • Looks like your default shell cmd is broken. Commented Sep 24, 2012 at 19:45
  • hmmm... that's strange. It looks like you have 64bit python installed? Are you on Win32? Or 64? It appears from your screenshot that you might be on a 32bit os. Just a guess. Commented Sep 24, 2012 at 19:45
  • Do these commands work if you run them from the command line? Commented Sep 24, 2012 at 19:45
  • Have you checked your environment variables to make sure they are setup correctly? Commented Sep 24, 2012 at 19:50
  • @Jakob what do you mean by cmd is broken :( Commented Sep 24, 2012 at 19:53

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Set the path in the environment settings by right clicking on your computer, as he mentioned above. See link: geekswithblogs.net/renso/archive/2009/10/21/…
i have already added python to my PATH variable, that's wahy the python is running in cmd prompt
The error you're getting is either due to cmd.exe not being on path or cmd.exe is corrupted. That -1 appears to be thrown when the os.system function can't start the cmd.exe (the shell) program.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.