Help us understand the problem. What is going on with this article?

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

はじめに

  • 以下のように表示され、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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした