LoginSignup
9
12

More than 3 years have passed since last update.

pip install --upgrade pipを実行したら、pipが使えなくなった

Posted at

はじめに

  • 以下のように表示され、pipが使用できなくなりました
$ pip
pyenv: pip: command not found

The `pip' command exists in these Python versions:
  anaconda3-5.1.0

TL;DR

pipを再インストールしました

Pythonのバージョン

$ python 
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct  6 2017, 12:04:38) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

再インストールまでの流れ

  • pipモジュールをインストールしましたが、Permission deniedとなり、失敗しました
$ python -m pip install -U pip

Collecting pip
  Using cached https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Users/hoge/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/pip-18.1.dist-info/INSTALLER'
Consider using the `--user` option or check the permissions.

You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
  • 調べてみると、pipをインストールできるスクリプトがあるとわかったので、一旦、pip周りをきれいにします
$ sudo python -m pip uninstall pip
The directory '/Users/hoge/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling pip-18.1:
  Would remove:
    /Users/hoge/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/pip-18.1.dist-info/*
    /Users/hoge/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/pip/*
Proceed (y/n)? y
  Successfully uninstalled pip-18.1
  • きれいになったので、pipをインストールするためのスクリプトをダウンロードします
$ wget https://bootstrap.pypa.io/get-pip.py
  • ダウンロードしたスクリプトを実行します
$ python get-pip.py 
Collecting pip
  Using cached https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl
  • 無事にpipコマンドが使用できるようになりました
$ pip -V
pip 19.1.1 from /Users/hoge/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/pip (python 3.6)

参考URL

9
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
12