2017-05-04

Mac Jupyter notebook

2017-0504 Mac Jupyter notebook

参考



インストールすると
sudo pip install jupyter
中略
エラーが出てしまう
OSError: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/share'

ぐぐると、この場所が問題らしい、Macでデフォルトでインストールされている場所が問題らしい
$ which python
/usr/bin/python

確認
$ sudo easy_install -mxN pip
Searching for pip
Best match: pip 9.0.1

Using /Library/Python/2.7/site-packages
Because this distribution was installed --multi-version, before you can
import modules from this package in an application, you will need to
'import pkg_resources' and then use a 'require()' call similar to one of
these examples, in order to select the desired version:

   pkg_resources.require("pip")  # latest installed version
   pkg_resources.require("pip==9.0.1")  # this exact version
   pkg_resources.require("pip>=9.0.1")  # this version or higher

インストールされたパッケージ一覧
$ cd /Library/Python/2.7/site-packages/
$ ls

Extras.pth pexpect-4.2.1.dist-info
IPython pickleshare-0.7.4.dist-info
Pygments-2.2.0.dist-info pickleshare.py
README pickleshare.pyc
_scandir.so pip
appnope pip-9.0.1.dist-info
appnope-0.1.0.dist-info prompt_toolkit
backports prompt_toolkit-1.0.14.dist-info
backports.shutil_get_terminal_size-1.0.0.dist-info ptyprocess
decorator-4.0.11.dist-info ptyprocess-0.5.1.dist-info
decorator.py pygments
decorator.pyc scandir-1.5.dist-info
enum scandir.py
enum34-1.1.6.dist-info scandir.pyc
ipython-5.3.0.dist-info shutil_backports
ipython_genutils simplegeneric-0.8.1.dist-info
ipython_genutils-0.2.0.dist-info simplegeneric.py
pathlib2-2.2.1.dist-info simplegeneric.pyc
pathlib2.py traitlets
pathlib2.pyc traitlets-4.3.2.dist-info
pep8-1.7.0.dist-info wcwidth
pep8.py wcwidth-0.1.7.dist-info
pep8.pyc wheel
pexpect wheel-0.29.0.dist-info


コマンドファイルを削除

$ sudo rm -rf /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg

$ sudo rm -rf /usr/local/bin/pip*

Version確認するとエラーとなる
$ pip -V
-bash: /usr/local/bin/pip: No such file or directory

pipの削除はこれでいいらしい

----------------------------------

Homebrew install

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew update
$ brew install python
$ pip install --upgrade pip setuptools
$ brew linkapps python

これでOK

確認

$ which python
/usr/local/bin/python

$ pip -V
pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)

パスを通す
echo 'export PATH=/usr/local/bin:$PATH'

パスの確認
echo $PATH

Mac再起動

$ python -V
Python 2.7.13

これでOK

----------------------------------

これでやっと、環境ができたので、再度インストール

sudo pip install jupyter

成功!

jupyter notebook

成功!


以上