MacにPythonをインストールする
概要
夏だ!仕事だ!!Excelだ!!!
設計書作成のため日々Excelをこねくり回してます。コードは一行も書いていません。それが今年いっぱい続きます。ってことでPythonインストールします。
インストール
すでにインストール済みでした。デフォルトのバージョンが2でHomebrewでPython3を別途インストールした記憶があります。
$ python -V Python 2.7.10 $ python3 -V Python 3.6.1
調べていたらHomebrewのPythonがデフォルトでバージョン3になったとありました。
$ brew upgrade
これで行けるかと思ったのですが、
$ python -V Python 2.7.10 $ python3 -V Python 3.7.0
python
コマンドは以前のままですね。
インストールし直してもダメ。
$ brew uninstall --force python $ brew install python
調べてみたら同じような人が!
$ brew info python python: stable 3.7.0 (bottled), HEAD ... ==> Caveats Python has been installed as /usr/local/bin/python3 Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into /usr/local/opt/python/libexec/bin ...
これだ!
.bash_profileにexport PATH=/usr/local/opt/python/libexec/bin:$PATH
を追記した結果、デフォルトでPython3になりましたね。
$ python -V Python 3.7.0 $ pip -V pip 18.0 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
Jupyter Notebook
Jupyter Notebookがいいと勧められたのでインストールします。
$ pip install jupyter
起動してみましょう。
$ mkdir jupyter-notebook $ cd jupyter-notebook/ $ jupyter notebook
これでPythonを始める準備が整ったはず。