WSL の Ubuntu に Jupyter Notebook をインストールしました

広告

Jupyter Notebook については、以前、記事を書いたことがあって、そのときに使いました。 今回は、 WSL の Ubuntu でも使えるようにインストールしてみました。

環境

  • Ubuntu 16.04 LTS
  • Python 3.5.2
  • jupyter-1.0.0

pip

WSL の Ubuntu の Python に pip がないので、 Python の仮想環境の中に pip をインストールするところから始めました。

$ python3 -m venv --without-pip jup
$ cd jup
$ ls
bin  include  lib  lib64  pyvenv.cfg
$ source bin/activate
(jup) $

仮想環境の jup を作成して、有効にしました。

pip をインストールするのに必要なファイルをダウンロードします。

(jup) $  curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1603k  100 1603k    0     0   424k      0  0:00:03  0:00:03 --:--:--  424k

ダウンロードできました。

仮想環境に pip をインストールします。

(jup) $ python get-pip.py
Collecting pip
  Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 1.6MB/s
Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/8c/10/79282747f9169f21c053c562a0baa21815a8c7879be97abd930dbcf862e8/setuptools-39.1.0-py2.py3-none-any.whl (566kB)
    100% |████████████████████████████████| 573kB 2.0MB/s
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/1b/d2/22cde5ea9af055f81814f9f2545f5ed8a053eb749c08d186b369959189a8/wheel-0.31.0-py2.py3-none-any.whl (41kB)
    100% |████████████████████████████████| 51kB 1.7MB/s
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-10.0.1 setuptools-39.1.0 wheel-0.31.0
(jup) $ which pip
/path/to/dir/jup/bin/pip

pip がインストールできました。

Installing Jupyter with pip

If you have Python 3 installed (which is recommended):

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

Project Jupyter | Install

Jupyter Notebook をインストールします。 仮想環境の中なので、そのまま pip コマンドでインストールしてしまいます。

(jup) $ pip install jupyter
Collecting jupyter
  Downloading https://files.pythonhosted.org/packages/83/df/0f5dd132200728a86190397e1ea87cd76244e42d39ec5e88efd25b2abd7e/jupyter-1.0.0-py2.py3-none-any.whl
Collecting ipywidgets (from jupyter)
  Downloading https://files.pythonhosted.org/packages/7d/24/fabc09ad81c6071159a4d12d5bfbddcbea69bd9e3b16c3250ef300c0285f/ipywidgets-7.2.1-py2.py3-none-any.whl (106kB)
    100% |████████████████████████████████| 112kB 1.0MB/s
Collecting qtconsole (from jupyter)
  Downloading https://files.pythonhosted.org/packages/90/ff/047e0dca2627b162866920e7aa93f04523c0ae81e5c67060eec85701992d/qtconsole-4.3.1-py2.py3-none-any.whl (108kB)
    100% |████████████████████████████████| 112kB 1.5MB/s
Collecting nbconvert (from jupyter)
  Downloading https://files.pythonhosted.org/packages/39/ea/280d6c0d92f8e3ca15fd798bbcc2ea141489f9539de7133d8fe10ea4b049/nbconvert-5.3.1-py2.py3-none-any.whl (387kB)
    100% |████████████████████████████████| 389kB 2.1MB/s
Collecting notebook (from jupyter)
  Downloading https://files.pythonhosted.org/packages/96/1f/e113875e6b8c8ee0e8c5748bf6fc942a109874adc9ca25248e95cf069803/notebook-5.4.1-py2.py3-none-any.whl (8.0MB)
    100% |████████████████████████████████| 8.0MB 748kB/s
Collecting ipykernel (from jupyter)
  Downloading https://files.pythonhosted.org/packages/ab/3f/cd624c835aa3336a9110d0a99e15070f343b881b7d651ab1375ef226a3ac/ipykernel-4.8.2-py3-none-any.whl (108kB)
    100% |████████████████████████████████| 112kB 1.9MB/s
Collecting jupyter-console (from jupyter)
  Downloading https://files.pythonhosted.org/packages/77/82/6469cd7fccf7958cbe5dce2e623f1e3c5e27f1bb1ad36d90519bc2d5d370/jupyter_console-5.2.0-py2.py3-none-any.whl
Collecting nbformat>=4.2.0 (from ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/da/27/9a654d2b6cc1eaa517d1c5a4405166c7f6d72f04f6e7eea41855fe808a46/nbformat-4.4.0-py2.py3-none-any.whl (155kB)
    100% |████████████████████████████████| 163kB 1.9MB/s
Collecting ipython>=4.0.0; python_version >= "3.3" (from ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/3a/eb/38a4491ebdbb0d5be6f72abc177a7a49f82541bbebbe5fbfe64b041a782b/ipython-6.3.1-py3-none-any.whl (749kB)
    100% |████████████████████████████████| 757kB 1.4MB/s
Collecting traitlets>=4.3.1 (from ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl (74kB)
    100% |████████████████████████████████| 81kB 1.8MB/s
Collecting widgetsnbextension~=3.2.0 (from ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/ff/fa/64acc09fc845a6b2dc0724d6f3f81e829b778ed5e9a7559567b4f19a3f4b/widgetsnbextension-3.2.1-py2.py3-none-any.whl (2.2MB)
    100% |████████████████████████████████| 2.2MB 1.2MB/s
Collecting jupyter-core (from qtconsole->jupyter)
  Downloading https://files.pythonhosted.org/packages/1d/44/065d2d7bae7bebc06f1dd70d23c36da8c50c0f08b4236716743d706762a8/jupyter_core-4.4.0-py2.py3-none-any.whl (126kB)
    100% |████████████████████████████████| 133kB 2.8MB/s
Collecting jupyter-client>=4.1 (from qtconsole->jupyter)
  Downloading https://files.pythonhosted.org/packages/94/dd/fe6c4d683b09eb05342bd2816b7779663f71762b4fa9c2d5203d35d17354/jupyter_client-5.2.3-py2.py3-none-any.whl (89kB)
    100% |████████████████████████████████| 92kB 1.1MB/s
Collecting pygments (from qtconsole->jupyter)
  Downloading https://files.pythonhosted.org/packages/02/ee/b6e02dc6529e82b75bb06823ff7d005b141037cb1416b10c6f00fc419dca/Pygments-2.2.0-py2.py3-none-any.whl (841kB)
    100% |████████████████████████████████| 849kB 1.5MB/s
Collecting ipython-genutils (from qtconsole->jupyter)
  Downloading https://files.pythonhosted.org/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting pandocfilters>=1.4.1 (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/4c/ea/236e2584af67bb6df960832731a6e5325fd4441de001767da328c33368ce/pandocfilters-1.4.2.tar.gz
Collecting jinja2 (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl (126kB)
    100% |████████████████████████████████| 133kB 2.5MB/s
Collecting mistune>=0.7.4 (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/c8/8c/87f4d359438ba0321a2ae91936030110bfcc62fef752656321a72b8c1af9/mistune-0.8.3-py2.py3-none-any.whl
Collecting testpath (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/15/19/d7bc380c479a184e4a5a9ce516e4e2a773165f89b445f7cdced83d94de25/testpath-0.3.1-py2.py3-none-any.whl (161kB)
    100% |████████████████████████████████| 163kB 2.3MB/s
Collecting bleach (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/30/b6/a8cffbb9ab4b62b557c22703163735210e9cd857d533740c64e1467d228e/bleach-2.1.3-py2.py3-none-any.whl
Collecting entrypoints>=0.2.2 (from nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/cc/8b/4eefa9b47f1910b3d2081da67726b066e379b04ca897acfe9f92bac56147/entrypoints-0.2.3-py2.py3-none-any.whl
Collecting terminado>=0.8.1 (from notebook->jupyter)
  Downloading https://files.pythonhosted.org/packages/2e/20/a26211a24425923d46e1213b376a6ee60dc30bcdf1b0c345e2c3769deb1c/terminado-0.8.1-py2.py3-none-any.whl
Collecting Send2Trash (from notebook->jupyter)
  Downloading https://files.pythonhosted.org/packages/49/46/c3dc27481d1cc57b9385aff41c474ceb7714f7935b1247194adae45db714/Send2Trash-1.5.0-py3-none-any.whl
Collecting tornado>=4 (from notebook->jupyter)
  Downloading https://files.pythonhosted.org/packages/cf/d1/3be271ae5eba9fb59df63c9891fdc7d8044b999e8ac145994cdbfd2ae66a/tornado-5.0.2.tar.gz (506kB)
    100% |████████████████████████████████| 512kB 1.5MB/s
Collecting prompt-toolkit<2.0.0,>=1.0.0 (from jupyter-console->jupyter)
  Downloading https://files.pythonhosted.org/packages/04/d1/c6616dd03701e7e2073f06d5c3b41b012256e42b72561f16a7bd86dd7b43/prompt_toolkit-1.0.15-py3-none-any.whl (247kB)
    100% |████████████████████████████████| 256kB 2.0MB/s
Collecting jsonschema!=2.5.0,>=2.4 (from nbformat>=4.2.0->ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/77/de/47e35a97b2b05c2fadbec67d44cfcdcd09b8086951b331d82de90d2912da/jsonschema-2.6.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=18.5 in ./lib/python3.5/site-packages (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter) (39.1.0)
Collecting pexpect; sys_platform != "win32" (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/b9/3c/e51a76fe78a877afd9acd95a51e3b7610c0983b19ef5a5dfa11735a619b8/pexpect-4.5.0-py2.py3-none-any.whl (57kB)
    100% |████████████████████████████████| 61kB 968kB/s
Collecting simplegeneric>0.8 (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/3d/57/4d9c9e3ae9a255cd4e1106bb57e24056d3d0709fc01b2e3e345898e49d5b/simplegeneric-0.8.1.zip
Collecting pickleshare (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/9f/17/daa142fc9be6b76f26f24eeeb9a138940671490b91cb5587393f297c8317/pickleshare-0.7.4-py2.py3-none-any.whl
Collecting decorator (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl
Collecting jedi>=0.10 (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/e7/42/074192a165622e645ed4aeade63e76e56b3496a044569b3c6cae3a918352/jedi-0.12.0-py2.py3-none-any.whl (172kB)
    100% |████████████████████████████████| 174kB 1.8MB/s
Collecting backcall (from ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/84/71/c8ca4f5bb1e08401b916c68003acf0a0655df935d74d93bf3f3364b310e0/backcall-0.1.0.tar.gz
Collecting six (from traitlets>=4.3.1->ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting python-dateutil>=2.1 (from jupyter-client>=4.1->qtconsole->jupyter)
  Downloading https://files.pythonhosted.org/packages/0c/57/19f3a65bcf6d5be570ee8c35a5398496e10a0ddcbc95393b2d17f86aaaf8/python_dateutil-2.7.2-py2.py3-none-any.whl (212kB)
    100% |████████████████████████████████| 215kB 1.6MB/s
Collecting pyzmq>=13 (from jupyter-client>=4.1->qtconsole->jupyter)
  Downloading https://files.pythonhosted.org/packages/4a/9c/c736101a42da5947985ff297c2837795f55a1c016cebcc3b49f31ce75c67/pyzmq-17.0.0-cp35-cp35m-manylinux1_x86_64.whl (3.1MB)
    100% |████████████████████████████████| 3.1MB 1.0MB/s
Collecting MarkupSafe>=0.23 (from jinja2->nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz
Collecting html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre (from bleach->nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/a5/62/bbd2be0e7943ec8504b517e62bab011b4946e1258842bc159e5dfde15b96/html5lib-1.0.1-py2.py3-none-any.whl (117kB)
    100% |████████████████████████████████| 122kB 1.7MB/s
Collecting ptyprocess; os_name != "nt" (from terminado>=0.8.1->notebook->jupyter)
  Downloading https://files.pythonhosted.org/packages/ff/4e/fa4a73ccfefe2b37d7b6898329e7dbcd1ac846ba3a3b26b294a78a3eb997/ptyprocess-0.5.2-py2.py3-none-any.whl
Collecting wcwidth (from prompt-toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter)
  Downloading https://files.pythonhosted.org/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Collecting parso>=0.2.0 (from jedi>=0.10->ipython>=4.0.0; python_version >= "3.3"->ipywidgets->jupyter)
  Downloading https://files.pythonhosted.org/packages/63/69/0c383765d192006330bfaae27a2c5d0933fb4760c5aacd933b8b19391693/parso-0.2.0-py2.py3-none-any.whl (90kB)
    100% |████████████████████████████████| 92kB 1.3MB/s
Collecting webencodings (from html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre->bleach->nbconvert->jupyter)
  Downloading https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
Building wheels for collected packages: pandocfilters, tornado, simplegeneric, backcall, MarkupSafe
  Running setup.py bdist_wheel for pandocfilters ... done
  Stored in directory: /home/user/.cache/pip/wheels/39/01/56/f1b08a6275acc59e846fa4c1e1b65dbc1919f20157d9e66c20
  Running setup.py bdist_wheel for tornado ... done
  Stored in directory: /home/user/.cache/pip/wheels/29/8c/cf/6a5a8f6e35d877c0cb72b109d21c34981504897ce9a605e599
  Running setup.py bdist_wheel for simplegeneric ... done
  Stored in directory: /home/user/.cache/pip/wheels/a9/28/53/f24776b4c5bcbe91aaf1f1e247bd6fadd17191aa12fac63902
  Running setup.py bdist_wheel for backcall ... done
  Stored in directory: /home/user/.cache/pip/wheels/98/b0/dd/29e28ff615af3dda4c67cab719dd51357597eabff926976b45
  Running setup.py bdist_wheel for MarkupSafe ... done
  Stored in directory: /home/user/.cache/pip/wheels/33/56/20/ebe49a5c612fffe1c5a632146b16596f9e64676768661e4e46
Successfully built pandocfilters tornado simplegeneric backcall MarkupSafe
Installing collected packages: tornado, decorator, six, ipython-genutils, traitlets, jupyter-core, python-dateutil, pyzmq, jupyter-client, wcwidth, prompt-toolkit, ptyprocess, pexpect, pygments, simplegeneric, pickleshare, parso, jedi, backcall, ipython, ipykernel, jsonschema, nbformat, terminado, pandocfilters, MarkupSafe, jinja2, mistune, testpath, webencodings, html5lib, bleach, entrypoints, nbconvert, Send2Trash, notebook, widgetsnbextension, ipywidgets, qtconsole, jupyter-console, jupyter
Successfully installed MarkupSafe-1.0 Send2Trash-1.5.0 backcall-0.1.0 bleach-2.1.3 decorator-4.3.0 entrypoints-0.2.3 html5lib-1.0.1 ipykernel-4.8.2 ipython-6.3.1 ipython-genutils-0.2.0 ipywidgets-7.2.1 jedi-0.12.0 jinja2-2.10 jsonschema-2.6.0 jupyter-1.0.0 jupyter-client-5.2.3 jupyter-console-5.2.0 jupyter-core-4.4.0 mistune-0.8.3 nbconvert-5.3.1 nbformat-4.4.0 notebook-5.4.1 pandocfilters-1.4.2 parso-0.2.0 pexpect-4.5.0 pickleshare-0.7.4 prompt-toolkit-1.0.15 ptyprocess-0.5.2 pygments-2.2.0 python-dateutil-2.7.2 pyzmq-17.0.0 qtconsole-4.3.1 simplegeneric-0.8.1 six-1.11.0 terminado-0.8.1 testpath-0.3.1 tornado-5.0.2 traitlets-4.3.2 wcwidth-0.1.7 webencodings-0.5.1 widgetsnbextension-3.2.1

Jupyter Notebook がインストールできました。

Running the Notebook

Basic Steps

  1. Start the notebook server from the command line:

    jupyter notebook
  2. You should see the notebook open in your browser.

Running the Notebook — Jupyter Documentation 4.1.1 alpha documentation

Jupyter Notebook を起動します。

(jup) $ jupyter notebook
[I 18:00:42.915 NotebookApp] Writing notebook server cookie secret to /home/user/.local/share/jupyter/runtime/notebook_cookie_secret
[I 18:00:44.532 NotebookApp] Serving notebooks from local directory: /path/to/dir/jup
[I 18:00:44.533 NotebookApp] 0 active kernels
[I 18:00:44.535 NotebookApp] The Jupyter Notebook is running at:
[I 18:00:44.536 NotebookApp] http://localhost:8888/?token=eb93546c0f1f16a2a1103f079adf4874a87ddadd28cf25ef
[I 18:00:44.537 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 18:00:44.539 NotebookApp] No web browser found: could not locate runnable browser.
[C 18:00:44.540 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=eb93546c0f1f16a2a1103f079adf4874a87ddadd28cf25ef

起動できました。

コンソールに出力されているトークンつきの URL (http://localhost:8888/?token=eb93546c0f1f16a2a1103f079adf4874a87ddadd28cf25ef) に、ブラウザーからアクセスします。

すると、 Jupyter Notebook が表示されました。

終わり

しばらく Python を使っていなかったのですが、 JavaScript の Chart.js と Jupyter Notebook をうまく使っていきたいです。 まず、 Jupyter Notebook でローソク足を表示してみようと思います。

18 May 2018 追記

ようやく Jupyter Notebook にローソク足を表示することができました。

広告
広告