Python not working in command prompt?

前端 未结 20 1834
迷失自我
迷失自我 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:11

    It finally worked!!!

    I needed to do things to get it to work

    1. Add C:\Python27\ to the end of the PATH system variable
    2. Add C:\Python27\ to the end of the PYTHONPATH system variable

    I had to add these to both for it to work.

    If I added any subdirectories, it did not work for some reason.

    Thank you all for your responses.

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

    Seems like the python executable is not found in your PATH, which defines where it is looking for executables. See the official instructions for instructions on how to get the python executables in your PATH.

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

    If you are working with command prompt and if you are facing the issue even after adding python path to system variable PATH.

    Remember to restart the command prompt (cmde.exe).

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

    Just go with the command py. I'm running python 3.6.2 on windows 7 and it works just fine.
    I removed all the python paths from the system directory and the paths don't show up when I run the command echo %path% in cmd. Python is still working fine.
    I ran into this by accidentally pressing enter while typing python...

    EDIT: I didn't mention that I installed python to a custom folder C:\Python\

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

    Add the python bin directory to your computer's PATH variable. Its listed under Environment Variables in Computer Properties -> Advanced Settings in Windows 7. It should be the same for Windows 8.

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

    Rather than the command "python", consider launching Python via the py launcher, as described in sg7's answer, which by runs your latest version of Python (or lets you select a specific version). The py launcher is enabled via a check box during installation (default: "on").

    Nevertheless, you can still put the "python" command in your PATH, either at "first installation" or by "modifying" an existing installation.


    First Installation:

    Checking the "[x] Add Python x.y to PATH" box on the very first dialog. Here's how it looks in version 3.8:

    This has the effect of adding the following to the PATH variable:

    C:\Users\...\AppData\Local\Programs\Python\Python38-32\Scripts\
    C:\Users\...\AppData\Local\Programs\Python\Python38-32\
    

    Modifying an Existing Installation:

    Re-run your installer (e.g. in Downloads, python-3.8.4.exe) and Select "Modify". Check all the optional features you want (likely no changes), then click [Next]. Check [x] "Add Python to environment variables", and [Install].

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