尝试在我的计算机上安装 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
原文由 user3597950 发布,翻译遵循 CC BY-SA 4.0 许可协议
您需要将 pip 安装路径添加到 PATH 系统变量 中。默认情况下,pip 安装到
C:\Python34\Scripts\pip
(pip 现在与新版本的 python 捆绑在一起),因此需要将路径“C:\Python34\Scripts”添加到您的 PATH 变量中。要检查它是否已经在您的 PATH 变量中,请在 CMD 提示符下键入
echo %PATH%
要将 pip 安装路径添加到 PATH 变量 中,可以使用控制面板或
setx
命令。例如:注意:根据 官方文档,“使用 setx 变量设置的 [v] 变量仅在未来的命令窗口中可用,在当前命令窗口中不可用”。特别是, _您需要在输入上述命令后启动一个新的 cmd.exe 实例_,以利用新的环境变量。
感谢 Scott Bartell 指出这一点。