Jupyter notebook(lab) のインストールと動作確認まで

目次

はじめに

jupyter notebookをインストールと起動確認を行います
*注 2022年現在はJupyter notebookの後継であるJupyterLabがおすすめみたいです。

Jupyter notebook のインストール

まずは、お約束のsudo apt list –upgradableとsudo apt upgradeです。

bio@bio:~$sudo apt list --upgradable 
[sudo] bio のパスワード: 
一覧表示... 完了 #[...からアップグレード可]とでたら下記を実行してください。
bio@bio:~$sudo apt upgrade
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
アップグレードパッケージを検出しています... 完了
アップグレード: 0 個、新規インストール: 0 個、削除: 0 個、保留: 0 個。
#今回はアップグレードするものがなかったので、全て0個になっています 
pipで入れる場合はpipをアップグレードします。
bio@bio:~$python3.10 -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /usr/local/lib/python3.10/site-packages (22.0.4)
#今回はすでにupgradeされていました。

jupyter-notebookをインストールします。
(pipの場合はpython3.10 -m pip install jupyterlabです)

bio@bio:~$sudo apt install jupyter-notebook 
[sudo] bio のパスワード: 
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  fonts-font-awesome fonts-glyphicons-halflings fonts-mathjax javascript-common jupyter-core jupyter-nbextension-jupyter-js-widgets
  libjs-backbone libjs-bootstrap libjs-bootstrap-tour libjs-codemirror libjs-es6-promise libjs-jed libjs-jquery libjs-jquery-typeahead
  libjs-jquery-ui libjs-marked libjs-mathjax libjs-moment libjs-requirejs libjs-requirejs-text libjs-text-encoding libjs-underscore
  libjs-xterm libnorm1 libpgm-5.2-0 libzmq5 pandoc pandoc-data python3-attr python3-backcall python3-bleach python3-decorator
  python3-defusedxml python3-distutils python3-html5lib python3-importlib-metadata python3-ipykernel python3-ipython
  python3-ipython-genutils python3-ipywidgets python3-jedi python3-jinja2 python3-jsonschema python3-jupyter-client
  python3-jupyter-core python3-mistune python3-more-itertools python3-nbconvert python3-nbformat python3-notebook
  python3-pandocfilters python3-parso python3-pickleshare python3-prometheus-client python3-prompt-toolkit python3-pygments
  python3-pyrsistent python3-send2trash python3-setuptools python3-terminado python3-testpath python3-tornado python3-traitlets
  python3-wcwidth python3-webencodings python3-widgetsnbextension python3-zipp python3-zmq
提案パッケージ:
  apache2 | lighttpd | httpd libjs-jquery-lazyload libjs-json libjs-jquery-ui-docs fonts-mathjax-extras fonts-stix libjs-mathjax-doc
  texlive-latex-recommended texlive-xetex texlive-luatex pandoc-citeproc texlive-latex-extra context wkhtmltopdf librsvg2-bin groff
  ghc nodejs php python ruby r-base-core node-katex python-attr-doc python-bleach-doc python3-genshi python3-lxml python-ipython-doc
  python-ipywidgets-doc python-jinja2-doc python-jsonschema-doc python3-pip python-nbconvert-doc python-notebook-doc
  python-pygments-doc ttf-bitstream-vera python-setuptools-doc python3-pycurl python-tornado-doc python3-twisted
以下のパッケージが新たにインストールされます:
  fonts-font-awesome fonts-glyphicons-halflings fonts-mathjax javascript-common jupyter-core jupyter-nbextension-jupyter-js-widgets
  jupyter-notebook libjs-backbone libjs-bootstrap libjs-bootstrap-tour libjs-codemirror libjs-es6-promise libjs-jed libjs-jquery
  libjs-jquery-typeahead libjs-jquery-ui libjs-marked libjs-mathjax libjs-moment libjs-requirejs libjs-requirejs-text
  libjs-text-encoding libjs-underscore libjs-xterm libnorm1 libpgm-5.2-0 libzmq5 pandoc pandoc-data python3-attr python3-backcall
  python3-bleach python3-decorator python3-defusedxml python3-distutils python3-html5lib python3-importlib-metadata python3-ipykernel
  python3-ipython python3-ipython-genutils python3-ipywidgets python3-jedi python3-jinja2 python3-jsonschema python3-jupyter-client
  python3-jupyter-core python3-mistune python3-more-itertools python3-nbconvert python3-nbformat python3-notebook
  python3-pandocfilters python3-parso python3-pickleshare python3-prometheus-client python3-prompt-toolkit python3-pygments
  python3-pyrsistent python3-send2trash python3-setuptools python3-terminado python3-testpath python3-tornado python3-traitlets
  python3-wcwidth python3-webencodings python3-widgetsnbextension python3-zipp python3-zmq
アップグレード: 0 個、新規インストール: 69 個、削除: 0 個、保留: 0 個。
32.0 MB のアーカイブを取得する必要があります。
この操作後に追加で 228 MB のディスク容量が消費されます。
続行しますか? [Y/n] Y

Yを入力しエンターキーを押すとインストールが始まります。
数分待つとインストールが終わり戻ってきます。

パスを通す

Jupyterlabの場合下記のような警告がでますので、pathを通す作業が必要でした。環境によってはでないかもしれません。詳しくはexportでダグってください。

WARNING: The scripts jupyter, jupyter-migrate and jupyter-troubleshoot are installed in '/home/bio/.local/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 '/home/bio/.local/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-server is installed in '/home/bio/.local/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 jlpm, jupyter-lab, jupyter-labextension and jupyter-labhub are installed in '/home/bio/.local/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.
bio@bio:~$export PATH="$PATH:/home/bio/.local/bin/"
#起動が確認できたらexport PATH="$PATH:/home/bio/.local/bin/"の一文を.bashrcに記載しておくと毎回入力しなくてすむ

Jupyter-notebookの起動

Jupyter-notebookと打ち込み起動します。

bio@bio:~$jupyter-notebook 
[I 02:37:56.462 NotebookApp] Writing notebook server cookie secret to /home/bio/.local/share/jupyter/runtime/notebook_cookie_secret
[I 02:37:56.558 NotebookApp] Serving notebooks from local directory: /home/bio
[I 02:37:56.558 NotebookApp] The Jupyter Notebook is running at:
...
...
...
#このあとにブラウザが立ち上がりjupyter-notebookが起動します。
#JupyterLabの場合は bio@bio:~$jupyter-lab です。



下記のようなWebブラウザ画面が立ち上がるので
NewからPython3をクリックします。
pythonの画面が立ち上がるので、とりあえずのhello worldで動作確認しましょう。
以上で終了です。
よかったらシェアしてね!
  • URLをコピーしました!

コメント

コメントする

目次