いろいろ備忘録日記

主に .NET とか Go とか Flutter とか Python絡みのメモを公開しています。

Pythonメモ-67 (JupyterLab試してみた) (JupyterLab is Ready for Users, conda, jupyter lab, PhosphorJS)

概要

JupyterLabのデイリーユースでも利用できるよレベルの版が出た模様。

blog.jupyter.org

以下のように記載されています。

tl;dr: JupyterLab is ready for daily use

以前のJupyter Notebookとはガラっと変わってタブ化などできるようになっているみたいですね

てことで、ちょっと試してみました。

インストール

インストールは、condaでインストールしました。

conda-forgeチャネルにあります。

⟩ conda create --name jupyterlab jupyterlab
Solving environment: done

## Package Plan ##

  environment location: /Users/xxxx/anaconda3/envs/jupyterlab

  added / updated specs: 
    - jupyterlab


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    setuptools-38.5.1          |           py36_0         525 KB
    send2trash-1.5.0           |           py36_0          16 KB
    pexpect-4.4.0              |           py36_0          73 KB
    notebook-5.4.0             |           py36_0         6.6 MB
    terminado-0.8.1            |           py36_1          21 KB
    jupyterlab-0.31.8          |           py36_0         8.5 MB
    ipykernel-4.8.2            |           py36_0         145 KB
    simplegeneric-0.8.1        |           py36_2           9 KB
    ------------------------------------------------------------
                                           Total:        15.9 MB

The following NEW packages will be INSTALLED:

    appnope:             0.1.0-py36hf537a9a_0 
    bleach:              2.1.2-py36_0         
    ca-certificates:     2017.08.26-ha1e5d58_0
    certifi:             2018.1.18-py36_0     
    decorator:           4.2.1-py36_0         
    entrypoints:         0.2.3-py36hd81d71f_2 
    html5lib:            1.0.1-py36h2f9c1c0_0 
    ipykernel:           4.8.2-py36_0         
    ipython:             6.2.1-py36h3dda519_1 
    ipython_genutils:    0.2.0-py36h241746c_0 
    jedi:                0.11.1-py36_0        
    jinja2:              2.10-py36hd36f9c5_0  
    jsonschema:          2.6.0-py36hb385e00_0 
    jupyter_client:      5.2.2-py36_0         
    jupyter_core:        4.4.0-py36h79cf704_0 
    jupyterlab:          0.31.8-py36_0        
    jupyterlab_launcher: 0.10.2-py36_0        
    libcxx:              4.0.1-h579ed51_0     
    libcxxabi:           4.0.1-hebd6815_0     
    libedit:             3.1-hb4e282d_0       
    libffi:              3.2.1-h475c297_4     
    libsodium:           1.0.15-hd9e47c5_0    
    markupsafe:          1.0-py36h3a1e703_1   
    mistune:             0.8.3-py36_0         
    nbconvert:           5.3.1-py36h810822e_0 
    nbformat:            4.4.0-py36h827af21_0 
    ncurses:             6.0-hd04f020_2       
    notebook:            5.4.0-py36_0         
    openssl:             1.0.2n-hdbc3d79_0    
    pandoc:              1.19.2.1-ha5e8f32_1  
    pandocfilters:       1.4.2-py36h3b0b094_1 
    parso:               0.1.1-py36hc90e01c_0 
    pexpect:             4.4.0-py36_0         
    pickleshare:         0.7.4-py36hf512f8e_0 
    pip:                 9.0.1-py36h1555ced_4 
    prompt_toolkit:      1.0.15-py36haeda067_0
    ptyprocess:          0.5.2-py36he6521c3_0 
    pygments:            2.2.0-py36h240cd3f_0 
    python:              3.6.4-hc167b69_1     
    python-dateutil:     2.6.1-py36h86d2abb_1 
    python.app:          2-py36h54569d5_7     
    pyzmq:               16.0.3-py36he48b5ad_0
    readline:            7.0-hc1231fa_4       
    send2trash:          1.5.0-py36_0         
    setuptools:          38.5.1-py36_0        
    simplegeneric:       0.8.1-py36_2         
    six:                 1.11.0-py36h0e22d5e_1
    sqlite:              3.22.0-h3efe00b_0    
    terminado:           0.8.1-py36_1         
    testpath:            0.3.1-py36h625a49b_0 
    tk:                  8.6.7-h35a86e2_3     
    tornado:             4.5.3-py36_0         
    traitlets:           4.3.2-py36h65bd3ce_0 
    wcwidth:             0.1.7-py36h8c6ec74_0 
    webencodings:        0.5.1-py36h3b9701d_1 
    wheel:               0.30.0-py36h5eb2c71_1
    xz:                  5.2.3-h0278029_2     
    zeromq:              4.2.2-ha360ad0_2     
    zlib:                1.2.11-hf3cbc9b_2    

Proceed ([y]/n)? y


Downloading and Extracting Packages
setuptools 38.5.1: ################################################################################################################# | 100% 
send2trash 1.5.0: ################################################################################################################## | 100% 
pexpect 4.4.0: ##################################################################################################################### | 100% 
notebook 5.4.0: #################################################################################################################### | 100% 
terminado 0.8.1: ################################################################################################################### | 100% 
jupyterlab 0.31.8: ################################################################################################################# | 100% 
ipykernel 4.8.2: ################################################################################################################### | 100% 
simplegeneric 0.8.1: ############################################################################################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate jupyterlab
#
# To deactivate an active environment, use
#
#     $ conda deactivate

$ conda activate jupyterlab

今回使っているバージョン

⟩ jupyter lab --version                                                                                                        (jupyterlab) 
0.31.8

起動

起動は以下のコマンドで行えます。

$ jupyter lab

実行すると、ターミナルには以下のログが表示され、自動でブラウザが開きます。

⟩ jupyter lab                                                                                                                  (jupyterlab) 
[I 18:44:18.345 LabApp] JupyterLab beta preview extension loaded from /Users/xxxx/anaconda3/envs/jupyterlab/lib/python3.6/site-packages/jupyterlab
[I 18:44:18.345 LabApp] JupyterLab application directory is /Users/xxxx/anaconda3/envs/jupyterlab/share/jupyter/lab
[W 18:44:18.349 LabApp] JupyterLab server extension not enabled, manually loading...
[I 18:44:18.350 LabApp] JupyterLab beta preview extension loaded from /Users/xxxx/anaconda3/envs/jupyterlab/lib/python3.6/site-packages/jupyterlab
[I 18:44:18.350 LabApp] JupyterLab application directory is /Users/xxxx/anaconda3/envs/jupyterlab/share/jupyter/lab
[I 18:44:18.359 LabApp] Serving notebooks from local directory: /Users/xxxx/tmp/pytmp
[I 18:44:18.359 LabApp] 0 active kernels
[I 18:44:18.359 LabApp] The Jupyter Notebook is running at:
[I 18:44:18.359 LabApp] http://localhost:8888/?token=5c4eaf8fb8717ddf020f790d236c1e1abe4b6e2221678437
[I 18:44:18.359 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:44:18.360 LabApp] 
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=5c4eaf8fb8717ddf020f790d236c1e1abe4b6e2221678437

起動すると以下のような感じです。

f:id:gsf_zero1:20180225210313p:plain

Notebook作ってみる

新規ノートブックは、起動時に表示されているランチャー画面からクリックすると起動できます。

f:id:gsf_zero1:20180225210433p:plain

使い方などは、今までのJupyter Notebookと同じです。

タブを分割して表示

JupyterLabで便利な機能の一つに、エディタを分割表示出来る点があります。

Notebookではこれが出来ませんでした。以下のような感じです。

f:id:gsf_zero1:20180225210639p:plain

分割する場合は、エディタのタブをドラッグすると、どのペインに表示するかが表示されます。

PhosphorJS?

上のブログ記事みると、以下のように記載されていました。

JupyterLab itself is co-developed on top of PhosphorJS, a new Javascript library for building extensible, high-performance, desktop-style web applications.

このUIは、PhosphorJSというJavascriptライブラリで実現されているみたいですね。

メモメモ。

phosphorjs.github.io

これ、なんて読むんだろ???

追記) フォスファーって読むみたいですね。 明けの明星・・・・かっこいいですね。

ejje.weblio.jp

追記 (2018/02/26)

herokuにjupyterlabをデプロイするためのリポジトリがアップされてましたね。アップしたのはrequestsとかで有名なkennethreitzさん。(herokuの方だったんですね)

github.com

twitter.com


過去の記事については、以下のページからご参照下さい。

サンプルコードは、以下の場所で公開しています。