Powerlineインストールでエラーになった際の対処方法
概要
MacにPowerlineを導入した際に困った点をメモする
環境情報
事象
Powerlineをインストールしようとしたことろ、エラーとなった
❯ sudo pip install powerline-status==2.4
Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run prefix=options.prefix_path, File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install **kwargs File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files isolated=self.isolated, File "/Library/Python/2.7/site-packages/pip/wheel.py", line 377, in move_wheel_files clobber(source, dest, False, fixer=fixer, filter=filter) File "/Library/Python/2.7/site-packages/pip/wheel.py", line 323, in clobber shutil.copyfile(srcfile, destfile) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile with open(dst, 'wb') as fdst: IOError: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/powerline'
原因
調べたところ、System Integrity Protection (SIP)が原因になっている模様 SIPはOS X El Capitanで導入されたセキュリティで、 これにより/Systemが変更できなくなってしまっており、」「Operation not permitted」が発生する。
解決方法
一時的にSIPを無効にすればよい ⌘+Rを押しながら再起動し、コンソール画面で以下を入力
# csrutil disable # reboot
再びインストールを実行するとエラーなく成功した。 インストール終了後、SIPはもとに戻す。
# csrutil enable # reboot