年も明けたので、Pythonに手を出してみようかと思い、
コマンドを実行してみました。
$ sudo pip install boto3
すると
The directory ‘/Users/userareaz.wordpress.com/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.
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the ‘pip install –upgrade pip’ command.
The directory ‘/Users/userareaz.wordpress.com/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.
Collecting boto3
Downloading boto3-1.2.3-py2.py3-none-any.whl (108kB)
100% |████████████████████████████████| 110kB 1.7MB/s
Requirement already satisfied (use –upgrade to upgrade): jmespath<1.0.0,>=0.7.1 in /Library/Python/2.7/site-packages (from boto3)
Collecting futures<4.0.0,>=2.2.0 (from boto3)
Downloading futures-3.0.3-py2-none-any.whl
Collecting botocore<1.4.0,>=1.3.0 (from boto3)
Downloading botocore-1.3.15-py2.py3-none-any.whl (2.1MB)
100% |████████████████████████████████| 2.1MB 227kB/s
Collecting python-dateutil<3.0.0,>=2.1 (from botocore<1.4.0,>=1.3.0->boto3)
Downloading python_dateutil-2.4.2-py2.py3-none-any.whl (188kB)
100% |████████████████████████████████| 192kB 2.1MB/s
Requirement already satisfied (use –upgrade to upgrade): docutils>=0.10 in /Library/Python/2.7/site-packages (from botocore<1.4.0,>=1.3.0->boto3)
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore<1.4.0,>=1.3.0->boto3)
Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: futures, six, python-dateutil, botocore, boto3
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File “/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py”, line 223, in main
status = self.run(options, args)
File “/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py”, line 299, in run
root=options.root_path,
File “/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py”, line 640, in install
requirement.uninstall(auto_confirm=True)
File “/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py”, line 726, in uninstall
paths_to_remove.remove(auto_confirm)
File “/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_uninstall.py”, line 125, in remove
renames(path, new_path)
File “/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py”, line 314, in renames
shutil.move(old, new)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 302, in move
copy2(src, real_dst)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 131, in copy2
copystat(src, dst)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”, line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: ‘/tmp/pip-nHWFG7-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info’
年始早々、エラーに悩まされるとは・・・。
でも、エラーの内容を見てると「six」ってのが悪そうです。
理由はわかりまへん。
とりあえず、Google先生に確認してみると
「ココを見ろ」と言われたので、チェックしてみると同じことになってる人が。
ということで、書かれてる通りのことをやってました。
$ sudo pip install –ignore-install six boto3
The directory ‘/Users/userareaz.wordpress.com/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.
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the ‘pip install –upgrade pip’ command.
The directory ‘/Users/userareaz.wordpress.com/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.
Collecting six
Downloading six-1.10.0-py2.py3-none-any.whl
Collecting boto3
Downloading boto3-1.2.3-py2.py3-none-any.whl (108kB)
100% |████████████████████████████████| 110kB 3.0MB/s
Collecting jmespath<1.0.0,>=0.7.1 (from boto3)
Downloading jmespath-0.9.0-py2.py3-none-any.whl
Collecting futures<4.0.0,>=2.2.0 (from boto3)
Downloading futures-3.0.3-py2-none-any.whl
Collecting botocore<1.4.0,>=1.3.0 (from boto3)
Downloading botocore-1.3.15-py2.py3-none-any.whl (2.1MB)
100% |████████████████████████████████| 2.1MB 190kB/s
Collecting python-dateutil<3.0.0,>=2.1 (from botocore<1.4.0,>=1.3.0->boto3)
Downloading python_dateutil-2.4.2-py2.py3-none-any.whl (188kB)
100% |████████████████████████████████| 192kB 1.6MB/s
Collecting docutils>=0.10 (from botocore<1.4.0,>=1.3.0->boto3)
Downloading docutils-0.12.tar.gz (1.6MB)
100% |████████████████████████████████| 1.6MB 248kB/s
Installing collected packages: six, jmespath, futures, python-dateutil, docutils, botocore, boto3
Running setup.py install for docutils
Successfully installed boto3-1.2.3 botocore-1.1.3 docutils-0.12 futures-3.0.3 jmespath-0.7.1 python-dateutil-1.5 six-1.4.1
いけました!
原因は、El Capitanにしたことにあるようです。
よくわかってないですが・・・。
ということで、これができたので、Python でSDKを叩いてみようかと。
Mac OS XはシステムとしてPythonを使っていて、ライブラリの検索パスの関係で、システム側が持っているsixがユーザー側のsix(pipでアップデートされるのはこっち)よりも先に見つかってしまうのです。面倒なんだよね、これ・・・
virtualenv使ってマメに環境切り分けるのが一番いいんですけど、面倒なのでこの方法取っちまいますねえ。