読者です 読者をやめる 読者になる 読者になる

python: pip 8.0.0 のバグ修正

pip が動作しない、壊れた? >> コードを一行修正して解決

(1)環境

MacOSX 10.10 Yosemite 

python 2.7.11

pip 8.0.0

 $ which pip

/Users/my_name/anaconda/bin/pip

 

(2)不具合

$ pip install -U pip
Traceback (most recent call last):
File "/Users/my_name/anaconda/bin/pip", line 4, in <module>
from pip import main
File "/Library/Python/2.7/site-packages/pip-8.0.0-py2.7.egg/pip/__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/Library/Python/2.7/site-packages/pip-8.0.0-py2.7.egg/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/Library/Python/2.7/site-packages/pip-8.0.0-py2.7.egg/pip/index.py", line 29, in <module>
from pip.wheel import Wheel, wheel_ext
File "/Library/Python/2.7/site-packages/pip-8.0.0-py2.7.egg/pip/wheel.py", line 32, in <module>
from pip import pep425tags
File "/Library/Python/2.7/site-packages/pip-8.0.0-py2.7.egg/pip/pep425tags.py", line 214, in <module>
supported_tags = get_supported()
File "/Library/Python/2.7/site-packages/pip-8.0.0-py2.7.egg/pip/pep425tags.py", line 162, in get_supported
arch = get_platform()
File "/Library/Python/2.7/site-packages/pip-8.0.0-py2.7.egg/pip/pep425tags.py", line 119, in get_platform
major, minor, micro = release.split('.')
ValueError: need more than 2 values to unpack

 

(3)Stackoverflowを真似て解決。

まさに同じタイミング(数時間差)で同じような問題に遭遇している人を発見。

python - Upgrading to latest pip caused ValueError - Stack Overflow

これを真似て、

/Library/Python/2.7/site-packages/pip-8.0.0-py2.7.egg/pip/pep425tags.py

の119行目を変更。

 

変更前のファイル状況

$ cd /Library/Python/2.7/site-packages/pip-8.0.0-py2.7.egg/pip/
$ ls -l
total 736
-rw-r--r-- 1 root wheel 10431 20 Jan 17:11 __init__.py
-rw-r--r-- 1 root wheel 9332 20 Jan 17:11 __init__.pyc
-rw-r--r-- 1 root wheel 584 20 Jan 17:11 __main__.py
-rw-r--r-- 1 root wheel 505 20 Jan 17:11 __main__.pyc
drwxr-xr-x 24 root wheel 816 20 Jan 17:11 _vendor
-rw-r--r-- 1 root wheel 11429 20 Jan 17:11 basecommand.py
-rw-r--r-- 1 root wheel 8973 20 Jan 17:11 basecommand.pyc
-rw-r--r-- 1 root wheel 10465 20 Jan 17:11 baseparser.py
-rw-r--r-- 1 root wheel 11286 20 Jan 17:11 baseparser.pyc
-rw-r--r-- 1 root wheel 15921 20 Jan 17:11 cmdoptions.py
-rw-r--r-- 1 root wheel 15621 20 Jan 17:11 cmdoptions.pyc
drwxr-xr-x 26 root wheel 884 20 Jan 17:11 commands
drwxr-xr-x 6 root wheel 204 20 Jan 17:11 compat
-rw-r--r-- 1 root wheel 31715 20 Jan 17:11 download.py
-rw-r--r-- 1 root wheel 25825 20 Jan 17:11 download.pyc
-rw-r--r-- 1 root wheel 7741 20 Jan 17:11 exceptions.py
-rw-r--r-- 1 root wheel 12902 20 Jan 17:11 exceptions.pyc
-rw-r--r-- 1 root wheel 36776 20 Jan 17:11 index.py
-rw-r--r-- 1 root wheel 34211 20 Jan 17:11 index.pyc
-rw-r--r-- 1 root wheel 6137 20 Jan 17:11 locations.py
-rw-r--r-- 1 root wheel 5013 20 Jan 17:11 locations.pyc
drwxr-xr-x 6 root wheel 204 20 Jan 17:11 models
drwxr-xr-x 6 root wheel 204 20 Jan 17:11 operations
-rw-r--r-- 1 root wheel 7210 20 Jan 17:11 pep425tags.py
-rw-r--r-- 1 root wheel 7393 20 Jan 17:11 pep425tags.pyc
drwxr-xr-x 12 root wheel 408 20 Jan 17:11 req
-rw-r--r-- 1 root wheel 156 20 Jan 17:11 status_codes.py
-rw-r--r-- 1 root wheel 414 20 Jan 17:11 status_codes.pyc
drwxr-xr-x 22 root wheel 748 20 Jan 17:11 utils
drwxr-xr-x 12 root wheel 408 20 Jan 17:11 vcs
-rw-r--r-- 1 root wheel 32030 20 Jan 17:11 wheel.py
-rw-r--r-- 1 root wheel 26062 20 Jan 17:11 wheel.pyc

 

オリジナルをコピーして別名保存。

$ sudo cp pep425tags.py pep425tags_original_my_name.py
$ ls -l
total 752
-rw-r--r-- 1 root wheel 10431 20 Jan 17:11 __init__.py
-rw-r--r-- 1 root wheel 9332 20 Jan 17:11 __init__.pyc
-rw-r--r-- 1 root wheel 584 20 Jan 17:11 __main__.py
-rw-r--r-- 1 root wheel 505 20 Jan 17:11 __main__.pyc
drwxr-xr-x 24 root wheel 816 20 Jan 17:11 _vendor
-rw-r--r-- 1 root wheel 11429 20 Jan 17:11 basecommand.py
-rw-r--r-- 1 root wheel 8973 20 Jan 17:11 basecommand.pyc
-rw-r--r-- 1 root wheel 10465 20 Jan 17:11 baseparser.py
-rw-r--r-- 1 root wheel 11286 20 Jan 17:11 baseparser.pyc
-rw-r--r-- 1 root wheel 15921 20 Jan 17:11 cmdoptions.py
-rw-r--r-- 1 root wheel 15621 20 Jan 17:11 cmdoptions.pyc
drwxr-xr-x 26 root wheel 884 20 Jan 17:11 commands
drwxr-xr-x 6 root wheel 204 20 Jan 17:11 compat
-rw-r--r-- 1 root wheel 31715 20 Jan 17:11 download.py
-rw-r--r-- 1 root wheel 25825 20 Jan 17:11 download.pyc
-rw-r--r-- 1 root wheel 7741 20 Jan 17:11 exceptions.py
-rw-r--r-- 1 root wheel 12902 20 Jan 17:11 exceptions.pyc
-rw-r--r-- 1 root wheel 36776 20 Jan 17:11 index.py
-rw-r--r-- 1 root wheel 34211 20 Jan 17:11 index.pyc
-rw-r--r-- 1 root wheel 6137 20 Jan 17:11 locations.py
-rw-r--r-- 1 root wheel 5013 20 Jan 17:11 locations.pyc
drwxr-xr-x 6 root wheel 204 20 Jan 17:11 models
drwxr-xr-x 6 root wheel 204 20 Jan 17:11 operations
-rw-r--r-- 1 root wheel 7210 20 Jan 17:11 pep425tags.py
-rw-r--r-- 1 root wheel 7393 20 Jan 17:11 pep425tags.pyc
-rw-r--r-- 1 root wheel 7210 21 Jan 09:22 pep425tags_original_my_name.py
drwxr-xr-x 12 root wheel 408 20 Jan 17:11 req
-rw-r--r-- 1 root wheel 156 20 Jan 17:11 status_codes.py
-rw-r--r-- 1 root wheel 414 20 Jan 17:11 status_codes.pyc
drwxr-xr-x 22 root wheel 748 20 Jan 17:11 utils
drwxr-xr-x 12 root wheel 408 20 Jan 17:11 vcs
-rw-r--r-- 1 root wheel 32030 20 Jan 17:11 wheel.py
-rw-r--r-- 1 root wheel 26062 20 Jan 17:11 wheel.pyc

 

デスクトップに移動させて編集し、それを元の場所に持ってきてoverride。

$ sudo mv /Users/my_name/Desktop/pep425tags.py .
$ ls -l
total 752
-rw-r--r-- 1 root wheel 10431 20 Jan 17:11 __init__.py
-rw-r--r-- 1 root wheel 9332 20 Jan 17:11 __init__.pyc
-rw-r--r-- 1 root wheel 584 20 Jan 17:11 __main__.py
-rw-r--r-- 1 root wheel 505 20 Jan 17:11 __main__.pyc
drwxr-xr-x 24 root wheel 816 20 Jan 17:11 _vendor
-rw-r--r-- 1 root wheel 11429 20 Jan 17:11 basecommand.py
-rw-r--r-- 1 root wheel 8973 20 Jan 17:11 basecommand.pyc
-rw-r--r-- 1 root wheel 10465 20 Jan 17:11 baseparser.py
-rw-r--r-- 1 root wheel 11286 20 Jan 17:11 baseparser.pyc
-rw-r--r-- 1 root wheel 15921 20 Jan 17:11 cmdoptions.py
-rw-r--r-- 1 root wheel 15621 20 Jan 17:11 cmdoptions.pyc
drwxr-xr-x 26 root wheel 884 20 Jan 17:11 commands
drwxr-xr-x 6 root wheel 204 20 Jan 17:11 compat
-rw-r--r-- 1 root wheel 31715 20 Jan 17:11 download.py
-rw-r--r-- 1 root wheel 25825 20 Jan 17:11 download.pyc
-rw-r--r-- 1 root wheel 7741 20 Jan 17:11 exceptions.py
-rw-r--r-- 1 root wheel 12902 20 Jan 17:11 exceptions.pyc
-rw-r--r-- 1 root wheel 36776 20 Jan 17:11 index.py
-rw-r--r-- 1 root wheel 34211 20 Jan 17:11 index.pyc
-rw-r--r-- 1 root wheel 6137 20 Jan 17:11 locations.py
-rw-r--r-- 1 root wheel 5013 20 Jan 17:11 locations.pyc
drwxr-xr-x 6 root wheel 204 20 Jan 17:11 models
drwxr-xr-x 6 root wheel 204 20 Jan 17:11 operations
-rw-r--r--@ 1 my_name staff 7203 21 Jan 09:24 pep425tags.py
-rw-r--r-- 1 root wheel 7393 20 Jan 17:11 pep425tags.pyc
-rw-r--r-- 1 root wheel 7210 21 Jan 09:22 pep425tags_original_my_name.py
drwxr-xr-x 12 root wheel 408 20 Jan 17:11 req
-rw-r--r-- 1 root wheel 156 20 Jan 17:11 status_codes.py
-rw-r--r-- 1 root wheel 414 20 Jan 17:11 status_codes.pyc
drwxr-xr-x 22 root wheel 748 20 Jan 17:11 utils
drwxr-xr-x 12 root wheel 408 20 Jan 17:11 vcs
-rw-r--r-- 1 root wheel 32030 20 Jan 17:11 wheel.py
-rw-r--r-- 1 root wheel 26062 20 Jan 17:11 wheel.pyc
$ pip install -U pip
Requirement already up-to-date: pip in /Library/Python/2.7/site-packages/pip-8.0.0-py2.7.egg

pipは無事に全て完了。