尝试在计算机上安装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
答案
You need to add the path of your pip installation to your PATH system variable 。默认情况下,PIP安装到C:\Python34\Scripts\pip
(PIP现在与Python的新版本捆绑在一起),因此需要将路径" C:\ Python34 \ scripts"添加到您的路径变量中。
要检查它是否已经在您的路径变量中,请键入echo %PATH%
在CMD提示下
To add the path of your pip installation to your PATH variable ,您可以使用控制面板或setx
命令。例如:
setx PATH "%PATH%;C:\Python34\Scripts"
Note :根据官方文件," [使用SETX变量设置的变量仅在未来命令窗口中可用,而不是当前命令窗口中的变量"。尤其,您需要启动一个新的cmd.exe实例输入上述命令以利用新的环境变量。
感谢Scott Bartell指出了这一点。