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

当前回答

我使用控制面板删除了旧版本,然后安装了新版本,但是即使在环境变量中添加了正确的路径,新版本也没有反映pip。然而,对我来说有用的是删除旧的python文件夹,即使在卸载后也在本地App文件夹中。对我来说,这条路就像下面。删除这个文件夹解决了我的问题

C:\Users\username\AppData\Local\Programs\Python38

其他回答

控制面板->添加/删除程序-> Python ->修改->可选功能(可以单击所有内容)然后按下一步->勾选“将Python添加到环境变量”->安装

这应该可以解决您的路径问题,因此跳转到命令提示符,现在可以使用pip了。

这些方法对我都没用,除了跑步

python -m pip install -U pip

然后按照建议将指定的目录添加到PATH,这样就可以工作了

最常见的是:

在cmd.exe中写入

python -m pip install --user [name of your module here without brackets]

我刚刚安装了Python 3.6.2。

我得到了路径

C:\Users\USERNAME\AppData\Local\Programs\Python\ Python36-32 \脚本

根据Python 3.6文档

在默认情况下,可能没有安装pip。一个 潜在的解决方案是:

python -m ensurepip --default-pip