Python not working in command prompt?

前端 未结 20 1835
迷失自我
迷失自我 2020-11-27 15:25

I type python into the command line, but the command prompt says that python is not recognized as an internal or external command, operable program, or batch fi

相关标签:
20条回答
  • 2020-11-27 16:01

    They gave us a script to do this for us already

    C:\Users\hUTBER\AppData\Local\Programs\Python\tools\scripts\win_add2path.py
    

    You'll need to make sure that you close and open the cmd otherwise it won't have the new path there.

    If you can't find this script these are the paths that it will add and I had to add manually in the end.

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

    Where mine and now python works in the cmd

    0 讨论(0)
  • 2020-11-27 16:01

    You need to add python to your PATH. I could be wrong, but Windows 7 should have the same cmd as Windows 8. Try this in the command line. Using setx permanently makes changes to you PATH. Note there are no equal signs, and quotes are used.

    setx PATH "%PYTHONPATH%;C:\python27"
    

    Set the c:\python27 to the directory of the python version you'd like to run from the typing python into the command prompt.

    0 讨论(0)
  • 2020-11-27 16:02

    Here's one for for office workers using a computer shared by others.

    I did put my user path in path and created the PYTHONPATH variables in my computer's PATH variable. Its listed under Environment Variables in Computer Properties -> Advanced Settings in Windows 7.

    Example:

    C:\Users\randuser\AppData\Local\Programs\Python\Python37

    This made it so I could use the command prompt.

    Hope this helped.

    0 讨论(0)
  • 2020-11-27 16:05

    The video was very useful.

    1. Go to system properties -> Advance ( or type "system env" in start menu.)
    2. Click environment variables
    3. Edit the 'PATH' variable
    4. Add 2 new paths 'C:\Python27' and 'C:\Python27\scripts'
    5. Run cmd again and type python.

    it worked for me

    0 讨论(0)
  • 2020-11-27 16:07

    You have to add the python executable in your SYSTEM PATH, do the following, My Computer > Properties > Advanced System Settings > Environment Variables > Then under system variables I create a new Variable called "PythonPath". In this variable I have "C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\other-foolder-on-the-path".

    enter image description here

    0 讨论(0)
  • 2020-11-27 16:08

    Even after following the instructions from the valuable answers above, calling python from the command line would open the Microsoft Store and redirect me to a page to download the software.

    I discovered this was caused by a 0 Ko python.exe file in AppData\Local\Microsoft\WindowsApps which was taking precedence over my python executable in my PATH.

    Removing this folder from my PATH solved it.

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