“python” and “pip” command not found in Command Line [duplicate]

点点圈 提交于 2020-01-30 11:34:06

问题


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?


回答1:


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!




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/46380299/python-and-pip-command-not-found-in-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!