1. ホーム
  2. python

[解決済み] 'pip'は内部コマンドとしても外部コマンドとしても認識されない

2022-03-21 02:01:37

質問

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

解決方法は?

システム変数PATHにpipをインストールしたパスを追加する必要があります。 . デフォルトでは、pipは以下の場所にインストールされます。 C:\Python34\Scripts\pip (現在、pipは新しいバージョンのpythonにバンドルされています)そのため、パス "C:\Python34³³Scripts" をPATH変数に追加する必要があります。

PATH変数にすでに含まれているかどうかを確認するには、次のように入力します。 echo %PATH% CMDプロンプトで

PATH変数にpipのインストールパスを追加するには を使用すると、コントロールパネルまたは setx コマンドを使用します。例えば

setx PATH "%PATH%;C:\Python34\Scripts"


備考 : によると 公式ドキュメント setx変数で設定された変数は、将来のコマンドウィンドウでのみ使用可能であり、現在のコマンドウィンドウでは使用できません。具体的には 新しいcmd.exeインスタンスを起動する必要があります。 新しい環境変数を利用するために、上記のコマンドを入力した後に、このコマンドを実行します。

ご指摘いただいたScott Bartell氏に感謝いたします。