なんだこれは

はてなダイアリーから移転しました。

Enjoy Solitude

Enjoy Solitude

jupyter notebook を pip でインストールする

TL;DR

jupyter の依存関係で 必要な tornado のインストールに失敗した。 tornado のインストール前にsetuptools いれておく。

python3 -m pip install --user upgrade
python3 -m pip install --user setuptools
python3 -m pip install --user jupyter

経緯

  • Pycham が起動しなくなってしまったので、
  • とりあえずの退避先として jupyter notebook を選択

jupyterのインストール

https://jupyter.org/install.html によると、とある。

python3 -m pip install --upgrade pip
python3 -m pip install jupyter

ローカルへインストール

ここではローカルにインストールするため --user を追加することにした。 以下を実行する。

python3 -m pip install --user --upgrade pip
python3 -m pip install --user jupyter

結果 setuptools がないのでインストールできませんと言われてしまう。

Collecting tornado>=4.2 (from ipykernel->jupyter)
  Using cached https://files.pythonhosted.org/packages/03/3f/5f89d99fca3c0100c8cede4f53f660b126d39e0d6a1e943e95cc3ed386fb/tornado-6.0.2.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named 'setuptools'
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/bp/_4wncwxj0z97ln0s0syx7lsr0000gn/T/pip-install-2lb8ioy9/tornado/

ひきつづき、setuptools をインストールして再度続きを行うとインストールできた。

python3 -m pip install --user setuptools
python3 -m pip install --user jupyter

ローカルインストール時の注意

ローカルにインストールした場合、スクリプトがパスにないためそのままでは実行できないことが警告される。

  WARNING: The script pygmentize is installed in '/Users/fu7mu4/Library/Python/3.5/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts jupyter, jupyter-migrate and jupyter-troubleshoot are installed in '/Users/fu7mu4/Library/Python/3.5/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts jupyter-kernel, jupyter-kernelspec and jupyter-run are installed in '/Users/fu7mu4/Library/Python/3.5/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts iptest, iptest3, ipython and ipython3 are installed in '/Users/fu7mu4/Library/Python/3.5/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script jsonschema is installed in '/Users/fu7mu4/Library/Python/3.5/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script jupyter-trust is installed in '/Users/fu7mu4/Library/Python/3.5/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script jupyter-nbconvert is installed in '/Users/fu7mu4/Library/Python/3.5/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts jupyter-bundlerextension, jupyter-nbextension, jupyter-notebook and jupyter-serverextension are installed in '/Users/fu7mu4/Library/Python/3.5/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script jupyter-console is installed in '/Users/fu7mu4/Library/Python/3.5/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

.bashrc や .bash_profile などで PATH に追加する必要がある。