简体   繁体   中英

Python not running from cmd in Windows 8 after upgrade

I can run the command line version of Python but I cannot seem to run it from the command prompt. I have recently upgraded from Windows 7 to Windows 8 and it worked fine with Windows 7. Now Windows 8 will not recognize Python. Thanks, William

The reason why it works from the Menu Item but not from the command prompt is that the menu item specifies the "Start in" directory where the Python executable can be found.

Chances are the Win 7 -> Win 8 upgrade failed to preserve the PATH environmental variable, where the path the Python was previously specified, allowing you to invoke Python from any command prompt console.

I installed as follows:

  • Python 3.3.2 Windows X86-64 MSI Installer
  • Windows 8
  • "Install for All Users"
  • turned on "Add python.exe to Path"

When I had completed, Python did not execute from a command shell.

I checked the environment variables, and, sure enough, "C:\\Python33\\", where I had installed it, was in the System environment variables.

But for some reason, "python" would only invoke Python at the command shell if I opened an administrator's command shell -- opening a non-privileged command shell would not include C:\\Python33\\ in the path.

My workaround was to create a PATH environment variable with value "C:\\Python33" as a User variable, and then it worked.

There may be other ways to do this. For example, rebooting or logging out & in may be worth trying.

See also:

  1. Go to C:\\python33 or wherever you installed it.
  2. Right click on "pythonw" and pin to taskbar,
  3. Run from taskbar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM