“python” and “pip” command not found in Command Li

2020-05-06 09:10发布

I recently installed Python 3.6 for my Windows 10 (64bit) and I want to use pip, but before to install that, I need to execute the following command using the downloaded get-pip.py program:

python get-pip.py

Somehow this doesn't work and I get the following message from Command Line:

'python' is not recognized as an internal or external command, 
operable program or batch file.

(I get the same message when I want to execute some pip commands)

I tried a lot of "solutions" for installing pip, like downloading files from https://bitbucket.org/pygame/pygame/downloads/ but nothing happened, I got the messages...

Could you explain to me why the Command Line doesn't know these commands and how can I install them?

3条回答
爷、活的狠高调
2楼-- · 2020-05-06 09:45

No need for admin access:

The reason the error is arising is because python is not in your PATH (meaning it can be called from any directory in the prompt). You can check that its not in the PATH by typing the following:

echo %path%

which will return lost of different directory paths, but not the one to where you have python installed.

To add python to this (and get rid of your error), follow these steps:

  1. Open up control panel.

  2. Go to System. (skip to this step with: Win+Break )

  3. Go to the Advanced tab at the top.

  4. Click on Environment Variables at the bottom.

  5. In the section User variables for ___, add a new one with New.

  6. In this pop-up add the name : path and value : C:\Python34 (or wherever it is installed).

Hope this helps as this is what I did to get python to work from any directory in the command prompt!

查看更多
别忘想泡老子
3楼-- · 2020-05-06 09:45

Open your CMD as administrator and type PATH (prints the output of your system PATH Variable). There have to be a PATH directing to your Python Installation directory. Only with that system Path your cmd knows where python.exe is and search there for python. Normally the Python Installation Setup asks if you want to set a Python Environment PATH Variable. Maybe run the setup again and watch out for that option. And I think there was a checkbox to automatic install pip for python.

If you want to set the Path Environment Variable use this:

https://superuser.com/questions/949560/how-do-i-set-system-environment-variables-in-windows-10

If you want to manually install pip with GET-PIP you have to download get-pip.py first and then run it with python. Download get-pip from here.

https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py

查看更多
贪生不怕死
4楼-- · 2020-05-06 09:52

Could you explain to me why the Command Line doesn't know these commands and how can I install them?

This happens when Python executables are not added to PATH. @xyres provided a nice link on how to do this.

I want to use pip, but before to install that, I need to execute the following command using the downloaded get-pip.py program:

pip should be bundled with the official Python installer, so there should be no need to get it from other sources

查看更多
登录 后发表回答