Jupyter Lab environment construction1. Install Jupyter Lab2. Open Jupyter Lab3. Set up LAN to access jupyter lab4. Set up access to jupyter lab5. Set jupyter lab to start automatically after booting
Jupyter Lab is a web-based interactive development environment that supports multiple programming languages; it provides a flexible workspace that can perform various data science tasks such as data cleaning, visualization, and machine learning modeling.
Check the system python version
Enter the command in the terminal:
python
Install Jupyter Lab
Update the repository list and software before installing the software:
xxxxxxxxxx
sudo apt update
sudo apt upgrade
Install Jupyter Lab in a Python 3 environment and enter the command in the terminal:
xxxxxxxxxx
sudo pip3 install jupyterlab
If the download fails multiple times, you can specify the Python software package mirror address of Tsinghua University to speed up domestic downloads:
xxxxxxxxxx
sudo pip3 install jupyterlab -i https://pypi.tuna.tsinghua.edu.cn/simple
Error reporting and resolution
If you directly enter the command to install Jupyter Lab in the terminal, an "error: externally-managed-environment" error will appear. You can use the following command to solve it: The python version is modified according to the version of your own system. My current system version is 3.11.
xxxxxxxxxx
sudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.bk
Installation success prompt
The following prompt appears indicating that the installation is successful.
Just enter jupyter lab in the terminal. If you need a password, you can follow the fourth step of the tutorial to set the password before using it!
xxxxxxxxxx
jupyterlab
xxxxxxxxxx
Before installing Jupyter Lab, select the system default browser, otherwise Jupyter Lab will not be started directly from the browser;
Use the sudo command to install jupyter lab. The warning message that appears can be ignored.
Create configuration file
The generated configuration file path is the path to the file that will be modified later.
xxxxxxxxxx
jupyter lab --generate-config
Modify configuration file
xxxxxxxxxx
sudo nano /home/pi/.jupyter/jupyter_lab_config.py
xxxxxxxxxx
Uncomment the content of the file and modify it to the following content: You can use the Ctrl+W shortcut key to search for keywords in the nano editor
c.ServerApp.allow_origin = '*'
c.ServerApp.ip = '0.0.0.0'
Press Ctrl+X, enter Y, then press Enter to save and exit editing!
Enter the command to set the password on the terminal. You need to enter it twice. Entering the password will not display the input content.
xxxxxxxxxx
jupyter lab password
Restart the Raspberry Pi after setting the password!
verify
Devices on the same LAN can enter IP:8888 in the browser to access!
xxxxxxxxxx
The password is the password set before: yahboom
After completing the above steps, you need to enter a command in the terminal every time you use juypter lab; for more convenient use, we can configure jupyter lab to start automatically at boot.
Configure startup items
Enter the following command in the terminal:
xxxxxxxxxx
sudo nano /etc/systemd/system/jupyter.service
Add the following content to the file:
xxxxxxxxxx
[Unit]
Description=Jupyter Lab
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/jupyter-lab
config=/home/pi/.jupyter/jupyter_lab_config.py --no-browser
User=pi
Group=pi
WorkingDirectory=/home/pi
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
pi: my current system username
ExecStart: The command to start Jupyter lab, change it to the installation path and configuration file path of JupyterLab (if the steps are all according to our operations, then enter the same path)
xxxxxxxxxx
Check the Jupyter-lab installation path: which jupyter-lab
The configuration file path refers to the path to the configuration file generated above.
WorkingDirectory: The working directory of Jupyter-lab, which can be changed by yourself
jupyter.service service
Enable auto-start at boot
xxxxxxxxxx
sudo systemctl enable jupyter
Disable auto-start at boot
xxxxxxxxxx
sudo systemctl disable jupyter
Start service
xxxxxxxxxx
sudo systemctl start jupyter
Out of service
xxxxxxxxxx
sudo systemctl stop jupyter
Check service status
xxxxxxxxxx
sudo systemctl status jupyter
Enter the enable jupyter.service service self-start and start service commands in the terminal and then restart the Raspberry Pi system.
After completing the above steps, you can access the LAN without typing jupyter lab in the terminal!