“python” not recognized as a command

后端 未结 12 1877
粉色の甜心
粉色の甜心 2020-11-22 14:01

I just downloaded and installed Python 2.7.2 to my laptop and I am trying to run some sample programs. My laptop is running Windows XP.

When I open a cmd

相关标签:
12条回答
  • 2020-11-22 14:52

    Another helpful but simple solution might be restarting your computer after doing the download if Python is in the PATH variable. This has been a mistake I usually make when downloading Python onto a new machine.

    After restarting my machine then Windows will often recognize Python in the PATH variable.

    0 讨论(0)
  • 2020-11-22 14:53

    I had the same problem for a long time. I just managed to resolve it.

    So, you need to select your Path, like the others said above. What I did:

    Open a command window. Write set path=C:\Python24 (put the location and the version for your python). Now type python, It should work.

    The annoying part with this is that you have to type it every time you open the CMD.

    I tried to do the permanent one (with the changes in the Environmental variables) but for me its not working.

    0 讨论(0)
  • 2020-11-22 14:55

    Further to @Udi post this is what the script tried to do, but did not work with me.

    I had to the set the following in the PATH nothing else.

    C:\Users\hUTBER\AppData\Local\Programs\Python\Python35
    C:\Users\hUTBER\AppData\Local\Programs\Python\Python35\Scripts
    

    Were mine and now python works in the cmd

    0 讨论(0)
  • 2020-11-22 14:57

    You need to add the python executable path to your Window's PATH variable.

    1. From the desktop, right-click My Computer and click Properties.
    2. In the System Properties window, click on the Advanced tab.
    3. In the Advanced section, click the Environment Variables button.
    4. Highlight the Path variable in the Systems Variable section and click the Edit button.
    5. Add the path of your python executable(c:\Python27\). Each different directory is separated with a semicolon. (Note: do not put spaces between elements in the PATH. Your addition to the PATH should read ;c:\Python27 NOT ; C\Python27)
    6. Apply the changes. You might need to restart your system, though simply restarting cmd.exe should be sufficient.
    7. Launch cmd and try again. It should work.
    0 讨论(0)
  • 2020-11-22 14:58

    emphasis: Remember to always RESTART the CMD WINDOW after setting the PATH environmental variable for it to take effect!

    0 讨论(0)
  • 2020-11-22 14:59

    You can do it in python installer:

    0 讨论(0)
提交回复
热议问题