Jupyter Notebook(ジュピター・ノートブック)をインストールする(Windows10)

スポンサーリンク

「Jupyter Notebook(ジュピター・ノートブック)」のインストールについて解説しています。(Windows10)

Jupyter Notebook(ジュピター・ノートブック)とは、オープンソースのWebアプリケーションです。ライブコード、数式、視覚化、説明テキストを含むドキュメントを作成して共有できます。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■Jupyter Notebookをインストールする

Jupyter Notebookをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install jupyter

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、pipを使う場合にはコマンドでの切り替えを行います。

py -3.8 -m pip install jupyter

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Collecting jupyter
Downloading jupyter-1.0.0-py2.py3-none-any.whl (2.7 kB)
Collecting qtconsole
Downloading qtconsole-5.0.1-py3-none-any.whl (118 kB)
|████████████████████████████████| 118 kB 1.3 MB/s
Collecting ipywidgets
Downloading ipywidgets-7.5.1-py2.py3-none-any.whl (121 kB)
|████████████████████████████████| 121 kB 2.2 MB/s
Collecting nbconvert
Downloading nbconvert-6.0.7-py3-none-any.whl (552 kB)
|████████████████████████████████| 552 kB 1.7 MB/s
Collecting jupyter-console
Downloading jupyter_console-6.2.0-py3-none-any.whl (22 kB)
Collecting notebook
Downloading notebook-6.1.5-py3-none-any.whl (9.5 MB)
|████████████████████████████████| 9.5 MB 3.3 MB/s
Collecting ipykernel
Downloading ipykernel-5.3.4-py3-none-any.whl (120 kB)
|████████████████████████████████| 120 kB 2.2 MB/s
Collecting ipython-genutils
Downloading ipython_genutils-0.2.0-py2.py3-none-any.whl (26 kB)
Collecting pyzmq>=17.1
Downloading pyzmq-20.0.0-cp38-cp38-win_amd64.whl (1.0 MB)
|████████████████████████████████| 1.0 MB 3.3 MB/s
Collecting jupyter-core
Downloading jupyter_core-4.7.0-py3-none-any.whl (82 kB)
|████████████████████████████████| 82 kB 418 kB/s
Collecting pygments
Downloading Pygments-2.7.2-py3-none-any.whl (948 kB)
|████████████████████████████████| 948 kB 2.2 MB/s
Collecting qtpy
Downloading QtPy-1.9.0-py2.py3-none-any.whl (54 kB)
|████████████████████████████████| 54 kB 495 kB/s
Collecting traitlets
Downloading traitlets-5.0.5-py3-none-any.whl (100 kB)
|████████████████████████████████| 100 kB 2.0 MB/s
Collecting jupyter-client>=4.1
Downloading jupyter_client-6.1.7-py3-none-any.whl (108 kB)
|████████████████████████████████| 108 kB 3.3 MB/s
Collecting nbformat>=4.2.0
Downloading nbformat-5.0.8-py3-none-any.whl (172 kB)
|████████████████████████████████| 172 kB 3.3 MB/s
Collecting ipython>=4.0.0; python_version >= “3.3”
Downloading ipython-7.19.0-py3-none-any.whl (784 kB)
|████████████████████████████████| 784 kB 3.3 MB/s
Collecting widgetsnbextension~=3.5.0
Downloading widgetsnbextension-3.5.1-py2.py3-none-any.whl (2.2 MB)
|████████████████████████████████| 2.2 MB 3.3 MB/s
Collecting pandocfilters>=1.4.1
Downloading pandocfilters-1.4.3.tar.gz (16 kB)
Collecting jupyterlab-pygments
Downloading jupyterlab_pygments-0.1.2-py2.py3-none-any.whl (4.6 kB)
Collecting jinja2>=2.4
Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
|████████████████████████████████| 125 kB 3.3 MB/s
Collecting mistune<2,>=0.8.1
Downloading mistune-0.8.4-py2.py3-none-any.whl (16 kB)
Collecting bleach
Downloading bleach-3.2.1-py2.py3-none-any.whl (145 kB)
|████████████████████████████████| 145 kB 3.3 MB/s
Collecting entrypoints>=0.2.2
Downloading entrypoints-0.3-py2.py3-none-any.whl (11 kB)
Collecting nbclient<0.6.0,>=0.5.0
Downloading nbclient-0.5.1-py3-none-any.whl (65 kB)
|████████████████████████████████| 65 kB 785 kB/s
Collecting defusedxml
Downloading defusedxml-0.6.0-py2.py3-none-any.whl (23 kB)
Collecting testpath
Downloading testpath-0.4.4-py2.py3-none-any.whl (163 kB)
|████████████████████████████████| 163 kB 3.3 MB/s
Collecting prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0
Downloading prompt_toolkit-3.0.8-py3-none-any.whl (355 kB)
|████████████████████████████████| 355 kB 3.3 MB/s
Collecting tornado>=5.0
Downloading tornado-6.1-cp38-cp38-win_amd64.whl (422 kB)
|████████████████████████████████| 422 kB 2.2 MB/s
Collecting prometheus-client
Downloading prometheus_client-0.9.0-py2.py3-none-any.whl (53 kB)
|████████████████████████████████| 53 kB 825 kB/s
Collecting Send2Trash
Downloading Send2Trash-1.5.0-py3-none-any.whl (12 kB)
Collecting terminado>=0.8.3
Downloading terminado-0.9.1-py3-none-any.whl (13 kB)
Collecting argon2-cffi
Downloading argon2_cffi-20.1.0-cp38-cp38-win_amd64.whl (42 kB)
|████████████████████████████████| 42 kB 338 kB/s
Requirement already satisfied: pywin32>=1.0; sys_platform == “win32” in c:\pg\python38\lib\site-packages (from jupyter-core->qtconsole->jupyter) (227)
Requirement already satisfied: python-dateutil>=2.1 in c:\pg\python38\lib\site-packages (from jupyter-client>=4.1->qtconsole->jupyter) (2.8.1)
Collecting jsonschema!=2.5.0,>=2.4
Downloading jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
|████████████████████████████████| 56 kB 973 kB/s
Requirement already satisfied: setuptools>=18.5 in c:\users\user\appdata\roaming\python\python38\site-packages (from ipython>=4.0.0; python_version >= “3.3”->ipywidgets->jupyter) (50.3.2)
Collecting decorator
Downloading decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
Collecting colorama; sys_platform == “win32”
Downloading colorama-0.4.4-py2.py3-none-any.whl (16 kB)
Collecting backcall
Downloading backcall-0.2.0-py2.py3-none-any.whl (11 kB)
Collecting jedi>=0.10
Downloading jedi-0.17.2-py2.py3-none-any.whl (1.4 MB)
|████████████████████████████████| 1.4 MB 2.2 MB/s
Collecting pickleshare
Downloading pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB)
Collecting MarkupSafe>=0.23
Downloading MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl (16 kB)
Collecting webencodings
Downloading webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
Collecting packaging
Downloading packaging-20.7-py2.py3-none-any.whl (35 kB)
Requirement already satisfied: six>=1.9.0 in c:\pg\python38\lib\site-packages (from bleach->nbconvert->jupyter) (1.15.0)
Collecting async-generator
Downloading async_generator-1.10-py3-none-any.whl (18 kB)
Collecting nest-asyncio
Downloading nest_asyncio-1.4.3-py3-none-any.whl (5.3 kB)
Collecting wcwidth
Downloading wcwidth-0.2.5-py2.py3-none-any.whl (30 kB)
Collecting pywinpty>=0.5; os_name == “nt”
Downloading pywinpty-0.5.7-cp38-cp38-win_amd64.whl (1.3 MB)
|████████████████████████████████| 1.3 MB 3.2 MB/s
Requirement already satisfied: cffi>=1.0.0 in c:\pg\python38\lib\site-packages (from argon2-cffi->notebook->jupyter) (1.14.3)
Collecting pyrsistent>=0.14.0
Downloading pyrsistent-0.17.3.tar.gz (106 kB)
|████████████████████████████████| 106 kB 3.3 MB/s
Requirement already satisfied: attrs>=17.4.0 in c:\pg\python38\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter) (20.3.0)
Collecting parso<0.8.0,>=0.7.0
Downloading parso-0.7.1-py2.py3-none-any.whl (109 kB)
|████████████████████████████████| 109 kB 3.3 MB/s
Collecting pyparsing>=2.0.2
Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
|████████████████████████████████| 67 kB 1.1 MB/s
Requirement already satisfied: pycparser in c:\pg\python38\lib\site-packages (from cffi>=1.0.0->argon2-cffi->notebook->jupyter) (2.20)
Using legacy ‘setup.py install’ for pandocfilters, since package ‘wheel’ is not installed.
Using legacy ‘setup.py install’ for pyrsistent, since package ‘wheel’ is not installed.
Installing collected packages: ipython-genutils, pyzmq, traitlets, jupyter-core, tornado, jupyter-client, decorator, colorama, pygments, backcall, parso, jedi, pickleshare, wcwidth, prompt-toolkit, ipython, ipykernel, qtpy, qtconsole, pyrsistent, jsonschema, nbformat, prometheus-client, Send2Trash, MarkupSafe, jinja2, pandocfilters, jupyterlab-pygments, mistune, webencodings, pyparsing, packaging, bleach, entrypoints, async-generator, nest-asyncio, nbclient, defusedxml, testpath, nbconvert, pywinpty, terminado, argon2-cffi, notebook, widgetsnbextension, ipywidgets, jupyter-console, jupyter
Running setup.py install for pyrsistent … done
Running setup.py install for pandocfilters … done
Successfully installed MarkupSafe-1.1.1 Send2Trash-1.5.0 argon2-cffi-20.1.0 async-generator-1.10 backcall-0.2.0 bleach-3.2.1 colorama-0.4.4 decorator-4.4.2 defusedxml-0.6.0 entrypoints-0.3 ipykernel-5.3.4 ipython-7.19.0 ipython-genutils-0.2.0 ipywidgets-7.5.1 jedi-0.17.2 jinja2-2.11.2 jsonschema-3.2.0 jupyter-1.0.0 jupyter-client-6.1.7 jupyter-console-6.2.0 jupyter-core-4.7.0 jupyterlab-pygments-0.1.2 mistune-0.8.4 nbclient-0.5.1 nbconvert-6.0.7 nbformat-5.0.8 nest-asyncio-1.4.3 notebook-6.1.5 packaging-20.7 pandocfilters-1.4.3 parso-0.7.1 pickleshare-0.7.5 prometheus-client-0.9.0 prompt-toolkit-3.0.8 pygments-2.7.2 pyparsing-2.4.7 pyrsistent-0.17.3 pywinpty-0.5.7 pyzmq-20.0.0 qtconsole-5.0.1 qtpy-1.9.0 terminado-0.9.1 testpath-0.4.4 tornado-6.1 traitlets-5.0.5 wcwidth-0.2.5 webencodings-0.5.1 widgetsnbextension-3.5.1

Enterキーを押すと、インストールが開始され、「Successfully installed」と表示されます。これが表示されれば、正常にインストールは完了となります。

■「Jupyter Notebook」を実行する

jupyter notebook

インストールの完了後、上記のコマンドを入力し、Enterキーを押します。

[I 12:48:09.736 NotebookApp] Writing notebook server cookie secret to C:\Users\user\AppData\Roaming\jupyter\runtime\notebook_cookie_secret
[I 12:48:10.276 NotebookApp] Serving notebooks from local directory: C:\Users\user
[I 12:48:10.276 NotebookApp] Jupyter Notebook 6.1.5 is running at:
[I 12:48:10.276 NotebookApp] http://localhost:8888/?token=f293aa09af36efaf21c83e56dd9d83b2a3c660947e8b3099
[I 12:48:10.276 NotebookApp] or http://00.0.0.1:8888/?token=f293aa09af36efaf21c83e56dd9d83b2a3c660947e8b3099
[I 12:48:10.276 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 12:48:10.421 NotebookApp]

To access the notebook, open this file in a browser:
file:///C:/Users/user/AppData/Roaming/jupyter/runtime/nbserver-17168-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=f293aa09af36efaf21c83e56dd9d83b2a3c660947e8b3099
or http://00.0.0.1:8888/?token=f293aa09af36efaf21c83e56dd9d83b2a3c660947e8b3099

Enterキーを押すと、コマンドプロンプトに上記のメッセージが表示されます。表示された後にWebブラウザが起動します。

起動後、「Home Page – Select or create a notebook(http://localhost:8888/tree)」のページが表示されます。

これでJupyter Notebookの実行が完了となります。

■Jupyter Notebookで新しいノートブックを作成する

Jupyter Notebookの実行後、新しいノートブックを作成する場合は、「Home Page – Select or create a notebook(http://localhost:8888/tree)」の右側にある「New」ボタンをクリックするとプルダウンメニューが表示され「Python 3」がありますので、こちらをクリックします。

クリックすると、「Untitled – Jupyter Notebook(http://localhost:8888/notebooks/Untitled.ipynb)」というページが表示されます。

これで新しいノートブックを作成は完了となります。

■ノートブックの終了

作成後、ノートブックを終了してみます。

終了する際は、作成したノートブックの「File」をクリックします。クリックするとプルダウンメニューが表示されますので、「Close and Halt(閉じて停止)」ボタンをクリックします。

クリックすると、作成されたノートブックが閉じて停止します。

■「Jupyter Notebook」を終了する

「Jupyter Notebook」を終了する場合は、作成されたノートブックが閉じて、コマンドプロンプトの画面を開き、「ctrl」と「c」キーを同時に押します。

[I 14:30:15.322 NotebookApp] Interrupted…
[I 14:30:15.323 NotebookApp] Shutting down 0 kernels
[I 14:30:15.324 NotebookApp] Shutting down 0 terminals

押すと、「Shutting down(シャットダウン)」と表示されますので、これでJupyter Notebookは終了となります。

あとは、Webブラウザで「Home Page – Select or create a notebook(http://localhost:8888/tree)」のページが表示されたままになりますので、ブラウザを終了します。

備考

作成されたノートブックを開いたまま、コマンドプロンプトの画面を開き、「ctrl」と「c」キーを同時に押すと下記のようなメッセージが表示されます。

Dead kernel(死んだカーネル)

The kernel has died, and the automatic restart has failed. It is possible the kernel cannot be restarted. If you are not able to restart the kernel, you will still be able to save the notebook, but running code will no longer work until the notebook is reopened.(カーネルが停止し、自動再起動に失敗しました。カーネルを再起動できない可能性があります。カーネルを再起動できない場合でもノートブックを保存することはできますが、ノートブックを再度開くまで実行コードは機能しません。)

Don’t Restart(再起動しない)

Try Restarting Now(今すぐ再起動してください)

コメント

タイトルとURLをコピーしました