2018年9月9日日曜日

JupyterLab をインストールしてみた

環境

  • Azure 上の Ubuntu 18.04.1 Server
  • Python 3.6.5

JupyterLab インストール

インストールしてバージョン確認

$ pip3 install jupyterlab
$ jupyter --version
4.4.0

Jupyter のバージョンが 5.3 より古い場合は以下実行する必要があるとのこと。

$ jupyter serverextension enable --py jupyterlab --sys-prefix
Enabling: jupyterlab
- Writing config: /home/worker/tmp/venv/etc/jupyter
    - Validating...
      jupyterlab 0.34.7 OK

NoteBook を RestructuredText にエクスポートする場合は pandoc が必要なのでインストール

$ sudo apt install pandoc

JupyterLab 起動

実行

$ jupyter lab
[I 09:13:48.928 LabApp] JupyterLab extension loaded from /home/worker/tmp/venv/lib/python3.6/site-packages/jupyterlab
[I 09:13:48.928 LabApp] JupyterLab application directory is /home/worker/tmp/venv/share/jupyter/lab
[W 09:13:48.932 LabApp] JupyterLab server extension not enabled, manually loading...
[I 09:13:48.933 LabApp] JupyterLab extension loaded from /home/worker/tmp/venv/lib/python3.6/site-packages/jupyterlab
[I 09:13:48.934 LabApp] JupyterLab application directory is /home/worker/tmp/venv/share/jupyter/lab
[I 09:13:48.936 LabApp] Serving notebooks from local directory: /home/worker/tmp
[I 09:13:48.937 LabApp] The Jupyter Notebook is running at:
[I 09:13:48.937 LabApp] http://localhost:8888/?token=fbdeaae80c3df681a58f38b44a39b15b0c4f10ea5ed7e570
[I 09:13:48.937 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 09:13:48.938 LabApp] No web browser found: could not locate runnable browser.
[C 09:13:48.938 LabApp]

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

ブラウザから JupyterLab に接続

JupyterLab を起動した時のメッセージによると、ブラウザから以下の URL に接続するようにとのこと

http://localhost:8888/?token=fbdeaae80c3df681a58f38b44a39b15b0c4f10ea5ed7e570

ssh で Ubuntu にログインしているので、ローカル側の localhost:8888 をサーバー側の localhost:8888 にポート転送

ローカル側のブラウザで指定の URL に接続


JupyterLab 終了

以下のどちらかの方法で終了することができます。

ブラウザから終了する方法

ブラウザの JupyterLab 画面のメニューで [File] - [Quit]

コンソールで終了する方法

JupyterLab を起動したコンソールで Ctrl + C を入力。

Shutdown this notebook server (y/[n])? と聞いてくるので、y を入力。 数秒以内に入力しないと Ctrl + C がキャンセルされます。


このブログのアイコンを作った

Twitter Card のデフォルト画像にする予定。