【CentOS8】Jupyterlab をインストールする
こういうの↓弊チームでもやりたいーーーと思ったので、Jupyter の動く環境を用意します。
今はJupyterLab
とやらが最新バージョン?みたいですね。
なので、まずはJupyterLab
がとりあえず動くところを目標に!
パスワードを設定したりサーバ証明書入れたりはまたの機会に...
現状確認
$ cat /etc/centos-release CentOS Linux release 8.2.2004 (Core) $ getenforce Enforcing
最新化
$ sudo dnf update -y; sudo reboot
必要なライブラリをインストール
今回 jupytherlab
は pip
でインストールするので、まずは pip
をインストールします。
$ sudo dnf install -y python3-pip
pip
をインストールしたことで python3
コマンドが使用可能になっています。
$ which python3 /usr/bin/python3 $ python3 --version Python 3.6.8
jupyterlab のインストール
サービス用のユーザとしてjupyter
を作成します。
$ sudo useradd -s /bin/bash -d /opt/jupyter jupyter
jupyter
ユーザとして jupyterlab をインストールします。
$ sudo su - jupyter -c 'pip3 install -U pip --user' $ sudo su - jupyter -c 'pip3 install -U jupyterlab --user'
jupyter のバージョン確認
$ sudo su - jupyter -c 'jupyter notebook --version' 6.0.3
jupyterlab の設定
jupyterlab の ListenPort 等を定義した Config を作成します。
$ sudo su - jupyter -c 'mkdir ~/.jupyter/' $ sudo su - jupyter -c 'tee ~/.jupyter/jupyter_notebook_config.py << _EOF_ > /dev/null c = get_config() c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False c.NotebookApp.port = 8888 c.NotebookApp.token = '' _EOF_'
※c.NotebookApp.token
がパスワード(平文)の定義です。今回は空(パスワードなし)で設定しています。
jupyterlab をデーモン化
.service
ファイルを作成し、 systemd
で自動起動させます。
$ sudo tee -a /etc/systemd/system/jupyter.service << _EOF_ > /dev/null [Unit] Description=Jupyter notebook [Service] Type=simple PIDFile=/var/run/jupyter-notebook.pid ExecStart=/opt/jupyter/.local/bin/jupyter lab User=jupyter Group=jupyter WorkingDirectory=/opt/jupyter Restart=always RestartSec=10 [Install] WantedBy=multi-user.target _EOF_ $ sudo systemctl daemon-reload $ sudo systemctl start jupyter $ sudo systemctl enable jupyter
Port 開放
Config に記述したポートを開放します。
$ sudo firewall-cmd --permanent --add-port 8888/tcp $ sudo firewall-cmd --reload
上記コマンド実行後に 'http://