概要
python を使用する機会があり、brew経由でインストールを行った。
ついで pip をインストールしようとしたところ下記のようなエラーがでてしまって pip のインストールができない。
これについて対応してみる。
$ easy_install Traceback (most recent call last): File "/usr/local/bin/easy_install", line 9, in <module> load_entry_point('setuptools==29.0.1', 'console_scripts', 'easy_install')() File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 357, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2394, in load_entry_point return ep.load() File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2108, in load entry = __import__(self.module_name, globals(),globals(), ['__name__']) File "build/bdist.macosx-10.11-intel/egg/setuptools/__init__.py", line 10, in <module> File "build/bdist.macosx-10.11-intel/egg/setuptools/extern/__init__.py", line 1, in <module> ImportError: No module named extern
調査する
brew を用いてインストールしたのだが、一度消してまた入れてみる
$ brew install python ==> Downloading https://homebrew.bintray.com/bottles/python-2.7.12_2.el_capitan.bottle.tar.gz Already downloaded: .../Caches/Homebrew/python-2.7.12_2.el_capitan.bottle.tar.gz ==> Pouring python-2.7.12_2.el_capitan.bottle.tar.gz ==> Using the sandbox Warning: The post-install step did not complete successfully You can try again using `brew postinstall python` ==> Caveats Pip and setuptools have been installed. To update them pip install --upgrade pip setuptools You can install Python packages with pip install <package> They will install into the site-package directory /usr/local/lib/python2.7/site-packages See: https://github.com/Homebrew/brew/blob/master/docs/Homebrew-and-Python.md .app bundles were installed. Run `brew linkapps python` to symlink these to /Applications. ==> Summary ? /usr/local/Cellar/python/2.7.12_2: 2,948 files, 39.8M
すると読み飛ばしていたのだがインストール後の処理が正常に完了していないようなことが表示されていた。
手動で実行してみると
$ brew postinstall python ==> Using the sandbox Error: Permission denied - /usr/local/lib/python2.7/site-packages/sitecustomize.py20161201-35997-9nuclf
すると権限がないようなことを言われる。これが原因か?
対応
brew は sudo で実行することはできないので(詳しくないができるかも。できても推奨していないが。)
権限で文句を言われている lib/python2.7 に直接一般ユーザでの権限を与える
$ sudo chown -R <user>:<group> /usr/local/lib/python2.7
そして再度後処理を実行してみる
$ brew postinstall python ==> Using the sandbox ==> /usr/local/Cellar/python/2.7.12_2/bin/python -s setup.py --no-user-cfg install --force --verbose ==> /usr/local/Cellar/python/2.7.12_2/bin/python -s setup.py --no-user-cfg install --force --verbose ==> /usr/local/Cellar/python/2.7.12_2/bin/python -s setup.py --no-user-cfg install --force --verbose
原因はよくわからないが動いた。easy_installも動作することが確認できました。
なんてことはありませんでした。
コメントを残す