【Python】pip install --upgrade pip が成功しない場合の対処法
小ネタです。
古い pip を使っていました
pip を使ってパッケージをインストールしたところ、以下のようなワーニングが。
You are using pip version 10.0.0, however version 19.3.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
現在 pip@10.0.0 を使っているようだけど、19.3.1 があるよ。'pip install --upgrade pip' でアップグレードできるよ。というワーニングですね。
問題
言われたとおりに実行。
$ pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: pip
Found existing installation: pip 10.0.0
Uninstalling pip-10.0.0:
You are using pip version 10.0.0, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
むむ。新しい pip のインストールには成功したみたいですが、10.0.0 がアンインストールできていないように見えます。引き続き、先程と同じワーニングが出ている。
解決策
sudo を使うとアンインストールまで成功しました。
$ sudo pip install --upgrade pip
Password:
Collecting pip
Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 1.5MB/s
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: pip
Found existing installation: pip 10.0.0
Uninstalling pip-10.0.0:
Successfully uninstalled pip-10.0.0
Successfully installed pip-19.3.1