我在电脑上安装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组件被检查并安装。

其他回答

我认为Python 2.7.9及更高版本已经预安装,它将在你的脚本文件夹中。

因此,您必须将“scripts”文件夹添加到路径中。我的安装在C:\Python27\Scripts中。检查你的路径,看看你的路径是什么,这样你就可以相应地改变下面的路径。然后转到PowerShell,在PowerShell中粘贴以下代码并按Enter键。在此之后,重新启动,您的问题将得到解决。

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27\Scripts", "User")

小说明:在“Windows 7 64位PC”中,添加后…Python34\脚本到路径变量,pip安装pygame不适合我。

所以我检查了“…Python34\Scripts"文件夹,它没有pip,但它有pip3和pip3.4。所以我运行pip3.4 install pygame .... .whl。它工作。

(进一步在下载pygame的文件夹中打开一个命令窗口…whl文件。)

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

  py -m pip

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

到目前为止,3.7.3版本在获得正确的系统变量方面遇到了一些问题。

试试这个:

在cmd中输入start %appdata%。 之后,文件资源管理器应该在../AppData/Roaming中弹出。

返回一个目录,找到Local/Programs/Python/Python37-32/Scripts。

注意:版本号可能不同,所以如果你复制和粘贴上面的文件路径,它不能工作。

这样做之后,您就有了下载的Python的正确位置。通过在地址栏中选择整个目录复制您的文件路径。

一旦你这样做了,点击开始图标并导航到控制面板→系统和安全→系统。然后点击面板左侧的“高级系统设置”。

在那里,单击右下角的环境变量,将出现两个框,一个上框和一个下框。在上面的框中:单击“Path”变量,然后单击位于右侧的编辑。单击New并粘贴您的目录Path。它应该看起来像这样:

单击OK三次,打开一个新的cmd窗口并输入:pip。看看它是否有效。

对于Python 2.7: 只需在命令提示符[以管理员身份运行]中使用此命令:

mklink /H pip.exe c:\python27\Scripts\pip.exe

结果: 为pip.exe创建硬链接<<===>> c:\python27\Scripts\pip.exe

和…:完成)