Mac
error
pip
update

macで pip 更新エラーについて

この記事はWanoアドベントカレンダーの21日目の記事です。

ある日、install pythonのlib時

あるmessage出てました

You are using pip version 8.1.2, however version 18.1 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

OK、普通の更新と思いますから

指示通り、以下の命令入れた:

~ pip install --upgrade pip

Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 784, in install
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 851, in install
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 462, in move_wheel_files
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 372, in make

File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 276, in _make_script
if self._is_nt and not outname.endswith('.' + ext): # pragma: no cover
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 250, in _write_script
script_bytes = launcher + shebang + linesep + zip_data
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/util.py", line 407, in write_binary_file

IOError: [Errno 13] Permission denied: '/usr/local/bin/pip'

権限足りない?ならば

~ sudo pip install --upgrade pip

Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
File "/Users/johnny/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 567, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Users/johnny/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 2604, in load_entry_point
return ep.load()
File "/Users/johnny/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 2264, in load
return self.resolve()
File "/Users/johnny/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 2274, in resolve
raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'main'

調べると、何がversionの問題っぽい

pip install --upgrade pip (10.0.0) 後の奇妙な挙動について

この時点既にpip動くできないので、取りあえず一旦10.0.0のversion前戻す

sudo python -m pip install pip==9.0.1

もしpip10に乗り換えたいなら、既存のパッケージに影響の可能性があるので、注意してください