pip 不是内部或外部命令
In this tutorial, we are going to see various possible reasons for getting the error ‘pip’ is not recognized as an internal or external command.
在本教程中,我们将看到导致错误“ pip”未被识别为内部或外部命令的各种可能原因。
Before starting with that let us first understand what pip is.
在开始之前,让我们首先了解什么是点子。
Pip is a package manager for python. Basically it is used to install packages, libraries and additional dependencies in case of Python. Previously pip was needed to be installed separately but since version 3.4 for Python 3 and version 2.7.9 for Python, it has been included in the Python installer.
Pip是python的软件包管理器。 基本上,它用于安装软件包,库和其他依赖项(如果使用Python)。 以前需要单独安装pip,但是自从Python 3版本3.4和Python 2.7.9版本起,它已包含在Python安装程序中。
We can get the error in case of pip because of the following reasons:
由于以下原因,我们在出现pip时会出现错误:
Pip is not installed:
未安装点子:
In case of any version above the mentioned versions of Python pip is most probably already installed on your computer.
如果是上述任何版本,则很可能已经在您的计算机上安装了上述提到的Python pip版本。
To check the version of python you are using simply run the command :
要检查您使用的python版本,只需运行以下命令:
python --version
If your python version is greater than the above mentioned versions the most probable reason for getting this error is that path to your pip installation is not added to your PATH variable.
如果您的python版本大于上述版本,则出现此错误的最可能原因是未将pip安装路径添加到PATH变量中。
To check the PATH variable you can use the command:
要检查PATH变量,可以使用以下命令:
echo %PATH%
By default, pip is present at C:\Python34\Scripts\pip. As pip comes bundled with python this path is to be added in the PATH variable, If it is not added you can add it to the PATH variable using the setx command:
默认情况下,C:\ Python34 \ Scripts \ pip中存在pip。 当pip与python捆绑在一起时,此路径将添加到PATH变量中;如果未添加,则可以使用setx命令将其添加到PATH变量中:
setx PATH "%PATH%;C:\Python34\Scripts"
If the above command doesn’t work in the first attempt restart the cmd prompt it should work properly then.
如果以上命令在第一次尝试中不起作用,请重新启动cmd提示符,然后它应该可以正常工作。
Alternatively, you can also add a path using the graphical interface of windows you can go to Settings-> Advanced -> Environment Variables. Select Path under User variables can click Edit, then you can add a new PATH. Just copy and paste the location of pip there (default C:\Python34\Scripts\pip ). This should solve the problem.
或者,您也可以使用Windows的图形界面添加路径,然后转到Settings-> Advanced-> Environment Variables 。 在“用户变量”下选择“路径”,可以单击“编辑”,然后可以添加新的PATH。 只需将pip的位置复制并粘贴到那里(默认为C:\ Python34 \ Scripts \ pip)。 这应该可以解决问题。
Note: If you are trying to do a fresh installation of python keep in mind to have the install pip and set PATH dialog box checked.
注意 :如果您尝试重新安装python,请记住选中安装pip和set PATH对话框。
If you are using an older version of python it is recommended that you upgrade your python version to the latest as support for the previous version is over. Even if in some cases you can get pip to work using commands like:
如果您使用的是python的旧版本,建议您将python版本升级到最新版本,因为对先前版本的支持已经结束。 即使在某些情况下,您也可以使用以下命令使pip正常工作:
python get-pip.py
You are going to run into a lot of problems because of the older version.
由于版本较旧,您将遇到很多问题。
For the latest python version, you can visit the python official website and download the latest version. Uninstall the previous version and install a fresh copy that will come bundled with pip and you can directly set PATH variables while doing the installation.
对于最新的python版本,您可以访问python官方网站并下载最新版本。 卸载以前的版本并安装将与pip捆绑在一起的新副本,您可以在安装时直接设置PATH变量。
Hope it solves the problem.
希望它能解决问题。
翻译自: https://www.thecrazyprogrammer.com/2020/03/pip-is-not-recognized-as-an-internal-or-external-command.html
pip 不是内部或外部命令