📌

Ubuntu22.04にJpyter Lab環境構築

2022/07/12に公開

環境

Windows 11 ProのVMware上にUbuntuを構築

apt upgrade

$ sudo apt -y upgrade

Python3がインストールされていることを確認

Ubuntu22.04はデフォでPython3.10がインストールされていました。

$ python3 -V
Python 3.10.4

pip3がインストールされていないのでインストールします

$ sudo apt install -y python3-pip

必要なパッケージのインストール

pip3 install Jupyter
pip3 install jupyterlab
pip3 install pandas
pip3 install numpy
pip3 install SciPy

jupyterlabのPATH追加

PATHを追加していないと、下記のとおりcomand not foundエラーとなります。

$ jupyter-lab --ip='0.0.0.0'
jupyter-lab: command not found

PATHの追加

export PATH="$HOME/.local/bin:$PATH"

jupyterlabの起動

$ jupyter-lab --ip='0.0.0.0'
[I 2022-07-12 02:48:33.732 ServerApp] jupyterlab | extension was successfully linked.
[I 2022-07-12 02:48:33.977 ServerApp] notebook_shim | extension was successfully linked.
[I 2022-07-12 02:48:33.999 ServerApp] notebook_shim | extension was successfully loaded.
[I 2022-07-12 02:48:34.001 LabApp] JupyterLab extension loaded from /home/kaneko/.local/lib/python3.10/site-packages/jupyterlab
[I 2022-07-12 02:48:34.001 LabApp] JupyterLab application directory is /home/kaneko/.local/share/jupyter/lab
[I 2022-07-12 02:48:34.006 ServerApp] jupyterlab | extension was successfully loaded.
[I 2022-07-12 02:48:34.007 ServerApp] Serving notebooks from local directory: /home/kaneko
[I 2022-07-12 02:48:34.007 ServerApp] Jupyter Server 1.18.1 is running at:
[I 2022-07-12 02:48:34.007 ServerApp] http://jupyternotebook:8888/lab?token=85a4c081685a21930c298b00e28ee23f834e16deb898d87d
[I 2022-07-12 02:48:34.008 ServerApp]  or http://127.0.0.1:8888/lab?token=85a4c081685a21930c298b00e28ee23f834e16deb898d87d
[I 2022-07-12 02:48:34.008 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 2022-07-12 02:48:34.012 ServerApp] No web browser found: could not locate runnable browser.
[C 2022-07-12 02:48:34.013 ServerApp]

    To access the server, open this file in a browser:
        file:///home/kaneko/.local/share/jupyter/runtime/jpserver-2492-open.html
    Or copy and paste one of these URLs:
        http://jupyternotebook:8888/lab?token=85a4c08168**********f834e16deb898d87d
     or http://127.0.0.1:8888/lab?token=85a4c08168**********f834e16deb898d87d

ブラウザからアクセスしてみる

アクセスする際の注意点
ログに出力されたportとtokenも入れてあげてください。
http://{ubuntuのIPアドレス}:8888/lab?token=85a4c08168**********f834e16deb898d87d

Discussion