我在电脑上安装Django时遇到了一个奇怪的错误。

这是我在命令行中输入的序列:

C:\Python34> python get-pip.py
Requirement already up-to-date: pip in c:\python34\lib\site-packages
Cleaning up...

C:\Python34> pip install Django
'pip' is not recognized as an internal or external command,
operable program or batch file.

C:\Python34> lib\site-packages\pip install Django
'lib\site-packages\pip' is not recognized as an internal or external command,
operable program or batch file.

是什么导致了这种情况?

这是当我输入echo %PATH%时得到的结果:

C:\Python34>echo %PATH%
C:\Program Files\ImageMagick-6.8.8-Q16;C:\Program Files (x86)\Intel\iCLS Client\
;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\S
ystem32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\
Windows Live\Shared;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Progr
am Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Intel\Intel(R) Mana
gement Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine C
omponents\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components
\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\P
rogram Files (x86)\nodejs\;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x
86)\git\cmd;C:\RailsInstaller\Ruby2.0.0\bin;C:\RailsInstaller\Git\cmd;C:\RailsIn
staller\Ruby1.9.3\bin;C:\Users\Javi\AppData\Roaming\npm

当前回答

进入控制面板>>卸载或更改程序,双击Python XXX修改安装。确保PIP组件被检查并安装。

其他回答

对于Mac,在终端窗口运行以下命令:

echo  export "PATH=$HOME/Library/Python/2.7/bin:$PATH"

在安装SQL 2019 Python时,PIP存在已知问题,需要修复(第7步) https://learn.microsoft.com/en-us/sql/advanced-analytics/known-issues-for-sql-server-machine-learning-services?view=sql-server-ver15

pip配置了需要TLS/SSL的位置,但是Python中的SSL模块不可用。

Workaround
Copy the following files:

libssl-1_1-x64.dll
libcrypto-1_1-x64.dll

from the folder 
C:\Program Files\Microsoft SQL Server\MSSSQL15.MSSQLSERVER\PYTHON_SERVICES\Library\bin
to the folder 
C:\Program Files\Microsoft SQL Server\MSSSQL15.MSSQLSERVER\PYTHON_SERVICES\DLLs

Then open a new DOS command shell prompt.

在Windows中,打开cmd并使用where python找到PYTHON_HOME的位置。现在将这个位置添加到您的环境变量PATH使用:

set PATH=%PATH%;<PYTHON_HOME>\Scripts

或者参考这个。


在Linux中,打开一个终端,并使用python找到PYTHON_HOME的位置。现在使用以下方法将PYTHON_HOME/Scripts添加到PATH变量中:

PATH=$PATH:<PYTHON_HOME>\Scripts
export PATH

我也面临着同样的问题。以管理员身份运行Windows PowerShell。它解决了我的问题。

在Python 3.6.2及以上最新版本中,可在

C:\Program Files (x86)\ Python36-32\脚本

您可以将该路径添加到我们的环境变量path中,如下所示

确保在设置路径后关闭命令提示符或Git。您还应该在管理员模式下打开命令提示符。这是Windows 10的例子。