我在电脑上安装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

当前回答

在Windows环境中,只需在DOS shell中执行以下命令。

路径= % %路径;D: \ \ python3.6.4 \脚本程序文件; (new path=当前路径;Python脚本文件夹的路径)

其他回答

在终端的Python文件夹路径中,只需键入

  py -m pip

为了检查您的pip的当前版本。 你还会看到一个命令列表,你可以使用…

我的命令是:

set PATH=%PATH%;C:\Python34\Scripts

(在echo %PATH%之后尝试,你会看到你的路径值为C:\Python34\Scripts)。

Thanks to:在Windows环境变量PATH中添加一个目录

我也有同样的问题。你只需要去你的

C: \ Python27 \脚本

并将其添加到环境变量中。路径设置完成后,只需在C:\Python27\Scripts上运行pip.exe文件,然后在cmd中尝试pip。但如果什么都没有发生,请尝试运行所有pip应用程序,如pip2.7和pip2.exe。皮普会像魔法一样管用。

在纠正我的PATH后,我继续收到这个错误。

如果您的代码库要求您拥有较早版本的Python(在我的例子中是2.7),那么它可能是pip存在之前的版本。

它不是很规范,但是安装一个最新的版本对我来说很有用。(我使用的是2.7.13。)

还有,长方法——这是在尝试了之前所有答案后的最后一招:

C:\python27\scripts\pip.exe install [package].whl

这是在车轮所在目录的cd后。