CentOS8上での作業記録(その2) -JupyterLabの導入と設定-

October 12, 2019 – 10:02 am

前回作成したanaconda 仮想環境py37_env上にJupyterLabをインストールし、必要な設定作業を行った。

インストール・設定作業ログをアップしておいた。

jupyter lab のインストール

(base) [anaconda@server02 ~]$ conda activate py37_env
(py37_env) [anaconda@server02 ~]$ conda install jupyterlab
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/anaconda/yes/envs/py37_env

  added / updated specs:
    - jupyterlab


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    attrs-19.2.0               |             py_0          39 KB
    jinja2-2.10.3              |             py_0          95 KB
    prompt_toolkit-2.0.10      |             py_0         227 KB
    traitlets-4.3.3            |           py37_0         138 KB
    ------------------------------------------------------------
                                           Total:         499 KB

The following NEW packages will be INSTALLED:

  attrs              pkgs/main/noarch::attrs-19.2.0-py_0
  backcall           pkgs/main/linux-64::backcall-0.1.0-py37_0
  bleach             pkgs/main/linux-64::bleach-3.1.0-py37_0
  decorator          pkgs/main/linux-64::decorator-4.4.0-py37_1
  defusedxml         pkgs/main/noarch::defusedxml-0.6.0-py_0
  entrypoints        pkgs/main/linux-64::entrypoints-0.3-py37_0
  gmp                pkgs/main/linux-64::gmp-6.1.2-h6c8ec71_1
  ipykernel          pkgs/main/linux-64::ipykernel-5.1.2-py37h39e3cac_0
  ipython            pkgs/main/linux-64::ipython-7.8.0-py37h39e3cac_0
  ipython_genutils   pkgs/main/linux-64::ipython_genutils-0.2.0-py37_0
  jedi               pkgs/main/linux-64::jedi-0.15.1-py37_0
  jinja2             pkgs/main/noarch::jinja2-2.10.3-py_0
  json5              pkgs/main/noarch::json5-0.8.5-py_0
  jsonschema         pkgs/main/linux-64::jsonschema-3.0.2-py37_0
  jupyter_client     pkgs/main/linux-64::jupyter_client-5.3.3-py37_1
  jupyter_core       pkgs/main/noarch::jupyter_core-4.5.0-py_0
  jupyterlab         pkgs/main/noarch::jupyterlab-1.1.4-pyhf63ae98_0
  jupyterlab_server  pkgs/main/noarch::jupyterlab_server-1.0.6-py_0
  libsodium          pkgs/main/linux-64::libsodium-1.0.16-h1bed415_0
  markupsafe         pkgs/main/linux-64::markupsafe-1.1.1-py37h7b6447c_0
  mistune            pkgs/main/linux-64::mistune-0.8.4-py37h7b6447c_0
  nbconvert          pkgs/main/linux-64::nbconvert-5.6.0-py37_1
  nbformat           pkgs/main/linux-64::nbformat-4.4.0-py37_0
  notebook           pkgs/main/linux-64::notebook-6.0.1-py37_0
  pandoc             pkgs/main/linux-64::pandoc-2.2.3.2-0
  pandocfilters      pkgs/main/linux-64::pandocfilters-1.4.2-py37_1
  parso              pkgs/main/noarch::parso-0.5.1-py_0
  pexpect            pkgs/main/linux-64::pexpect-4.7.0-py37_0
  pickleshare        pkgs/main/linux-64::pickleshare-0.7.5-py37_0
  prometheus_client  pkgs/main/noarch::prometheus_client-0.7.1-py_0
  prompt_toolkit     pkgs/main/noarch::prompt_toolkit-2.0.10-py_0
  ptyprocess         pkgs/main/linux-64::ptyprocess-0.6.0-py37_0
  pygments           pkgs/main/noarch::pygments-2.4.2-py_0
  pyrsistent         pkgs/main/linux-64::pyrsistent-0.15.4-py37h7b6447c_0
  python-dateutil    pkgs/main/linux-64::python-dateutil-2.8.0-py37_0
  pyzmq              pkgs/main/linux-64::pyzmq-18.1.0-py37he6710b0_0
  send2trash         pkgs/main/linux-64::send2trash-1.5.0-py37_0
  six                pkgs/main/linux-64::six-1.12.0-py37_0
  terminado          pkgs/main/linux-64::terminado-0.8.2-py37_0
  testpath           pkgs/main/linux-64::testpath-0.4.2-py37_0
  tornado            pkgs/main/linux-64::tornado-6.0.3-py37h7b6447c_0
  traitlets          pkgs/main/linux-64::traitlets-4.3.3-py37_0
  wcwidth            pkgs/main/linux-64::wcwidth-0.1.7-py37_0
  webencodings       pkgs/main/linux-64::webencodings-0.5.1-py37_1
  zeromq             pkgs/main/linux-64::zeromq-4.3.1-he6710b0_3


Proceed ([y]/n)? y


Downloading and Extracting Packages
attrs-19.2.0         | 39 KB     |                                                                                                                                         |   0% 
attrs-19.2.0         | 39 KB     | ######################################################8                                                                                 |  41% 
attrs-19.2.0         | 39 KB     | ####################################################################################################################################### | 100% 
traitlets-4.3.3      | 138 KB    |                                                                                                                                         |   0% 
traitlets-4.3.3      | 138 KB    | ####################################################################################################################################### | 100% 
prompt_toolkit-2.0.1 | 227 KB    |                                                                                                                                         |   0% 
prompt_toolkit-2.0.1 | 227 KB    | ####################################################################################################################################### | 100% 
jinja2-2.10.3        | 95 KB     |                                                                                                                                         |   0% 
jinja2-2.10.3        | 95 KB     | ####################################################################################################################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

jupyter_labをlocal host外から使用するための設定
 jupyter lab は、デフォルトでは、loal hostからのみ接続可能。local host外からアクセス可能にするには、Jupyter lab(notebook)のconfiguration fileで設定する必要がある。設定方法は、jupyter lab(notebook) の公式ドキュメントに詳しい。

(1) configuration file(jupyter_notebook_config.py)の設定内容(関連部のみ):

# Configuration file for jupyter-notebook.
#                   prepared on 2019/10/11
#

# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'

## Whether to open in a browser after starting. The specific browser used is
#  platform dependent and determined by the python standard library `webbrowser`
#  module, unless it is overridden using the --browser (NotebookApp.browser)
#  configuration option.
c.NotebookApp.open_browser = False

## Hashed password to use for web authentication.
#
#  To generate, type in a python/IPython shell:
#
#    from notebook.auth import passwd; passwd()
#
#  The string should be of the form type:salt:hashed-password.
c.NotebookApp.password = u'<hashed password placed here- >'

## The port the notebook server will listen on.
c.NotebookApp.port = 8888

(2) port 8888/tcp を追加

[root@server02 ~]# firewall-cmd --add-port=8888/tcp --zone=public --permanent
success
[root@server02 ~]# firewall-cmd --reload
success
[root@server02 ~]# firewall-cmd --list-ports --zone=public --permanent
8888/tcp

(3) hashed password の作成

(py37_env) [anaconda@server02 ~]$ ipython
Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from IPython.lib import passwd                                                                                                                                         
In [2]: passwd()                                                                                                                                                               
Enter password: 
Verify password: 
Out[2]: 'sha1:2d053f6c4356:88989a6d95e13d1e00246b34560595403584d0d8'

In [3]: exit()

(4) jupter lab 動作開始時ログ

(py37_env) [anaconda@server02 ~]$ jupyter lab
[W 09:16:32.020 LabApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 09:16:32.064 LabApp] JupyterLab extension loaded from /home/anaconda/yes/envs/py37_env/lib/python3.7/site-packages/jupyterlab
[I 09:16:32.064 LabApp] JupyterLab application directory is /home/anaconda/yes/envs/py37_env/share/jupyter/lab
[I 09:16:32.066 LabApp] Serving notebooks from local directory: /home/anaconda
[I 09:16:32.066 LabApp] The Jupyter Notebook is running at:
[I 09:16:32.066 LabApp] http://server02.yamasnet.com:8888/
[I 09:16:32.066 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

上掲したログの最初にWARNINGが表示され、ここでnotebook serverが全てのIPアドレスから接続可能になっていながら適切な暗号化措置(ecryption)がとられてない旨が警告されている。我がサーバではLAN外からはproxy経由で使用する構成にしている(「
Jupyter Notebook をLANの外から使うためのApacheの設定」参照)

その他必要な設定
jupyter lab の運用には、nodejs を必要とする。
以下、nodejsのインストールログを示す:

(py37_env) [anaconda@server02 ~]$ conda install nodejs
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/anaconda/yes/envs/py37_env

  added / updated specs:
    - nodejs


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    nodejs-10.13.0             |       he6710b0_0        13.0 MB
    ------------------------------------------------------------
                                           Total:        13.0 MB

The following NEW packages will be INSTALLED:

  nodejs             pkgs/main/linux-64::nodejs-10.13.0-he6710b0_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
nodejs-10.13.0       | 13.0 MB   |                                                                                                                                       |   0% 
nodejs-10.13.0       | 13.0 MB   | 1                                                                                                                                     |   0% 
nodejs-10.13.0       | 13.0 MB   | ##########2                                                                                                                           |   8% 
nodejs-10.13.0       | 13.0 MB   | #####################8                                                                                                                |  16% 
nodejs-10.13.0       | 13.0 MB   | #################################3                                                                                                    |  25% 
nodejs-10.13.0       | 13.0 MB   | ############################################8                                                                                         |  34% 
nodejs-10.13.0       | 13.0 MB   | ########################################################4                                                                             |  42% 
nodejs-10.13.0       | 13.0 MB   | ###################################################################9                                                                  |  51% 
nodejs-10.13.0       | 13.0 MB   | ###############################################################################5                                                      |  60% 
nodejs-10.13.0       | 13.0 MB   | ###########################################################################################                                           |  68% 
nodejs-10.13.0       | 13.0 MB   | ######################################################################################################6                               |  77% 
nodejs-10.13.0       | 13.0 MB   | ##################################################################################################################1                   |  86% 
nodejs-10.13.0       | 13.0 MB   | #############################################################################################################################7        |  95% 
nodejs-10.13.0       | 13.0 MB   | ##################################################################################################################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

参考: JupyterLab 関連公式ドキュメント

関連ポスト:


Post a Comment