Welcome to Raspberry Pi 5 repository
1.Jupyter Lab environment construction
Jupyter Lab Environment Setup
Jupyter Lab Environment Setup1. Install Jupyter Lab2. Open Jupyter Lab3. Set Up LAN Access for Jupyter Lab4. Set Up Access for Jupyter Lab5. Set Jupyter Lab to Start on Boot
If you are using the factory image we provided, manual installation and configuration are not required.
Jupyter Lab is a web-based interactive development environment that supports multiple programming languages. It provides a flexible workspace for data cleaning, visualization, machine learning modeling, and various other data science tasks.
1. Install Jupyter Lab
Check system Python version:
Enter the following command in the terminal:
python
Install Jupyter Lab:
Before installing software, first update the repository list and software:
xxxxxxxxxxsudo apt updatesudo apt upgrade

Install Jupyter Lab in the Python 3 environment. Enter the following command in the terminal:
xxxxxxxxxxsudo pip3 install jupyterlab
If download fails multiple times, you can specify the Tsinghua University Python package mirror address to speed up domestic downloads:
xxxxxxxxxxsudo pip3 install jupyterlab -i https://pypi.tuna.tsinghua.edu.cn/simple
Error Resolution:
Entering the Jupyter Lab installation command directly in the terminal will result in the "error: externally-managed-environment" error. You can solve this using the following command. Modify the Python version according to your system version. My current system version is 3.11:
xxxxxxxxxxsudo mv /usr/lib/python3.11/EXTERNALLY-MANAGED /usr/lib/python3.11/EXTERNALLY-MANAGED.bk

Success Message:
The following message indicates successful installation:

2. Open Jupyter Lab
Enter jupyter lab in the terminal. If a password is required, follow step 4 in the tutorial to set the password first before using!
xxxxxxxxxxjupyter lab

xxxxxxxxxxBefore installing Jupyter Lab, select the system's default browser first. Otherwise, Jupyter Lab will not start directly from the browser.When using the sudo command for Jupyter Lab installation, the warning message can be ignored.
3. Set Up LAN Access for Jupyter Lab
Create configuration file:
The generated configuration file path is the path to modify:
xxxxxxxxxxjupyter lab --generate-config

Modify configuration file:
xxxxxxxxxxsudo nano /home/pi/.jupyter/jupyter_lab_config.pyRemove comments from the file content and modify to the following. In the nano editor, you can use Ctrl+W shortcut to search for keywords:c.ServerApp.allow_origin = '*'c.ServerApp.ip = '0.0.0.0'
Press Ctrl+X, enter Y, then press Enter to save and exit!

4. Set Up Access for Jupyter Lab
Enter the password setting command in the terminal. You need to enter it twice. The entered password will not be displayed:
xxxxxxxxxxjupyter lab password

Restart Raspberry Pi after setting the password!
Verification:
Devices on the same LAN can access by entering IP:8888 in the browser!
xxxxxxxxxxThe password is the one you set earlier: yahboom

5. Set Jupyter Lab to Start on Boot
After completing the above steps, you need to enter the command in the terminal to use Jupyter Lab each time. For more convenience, we can configure Jupyter Lab to start automatically on boot.
Configure startup item:
Enter the following command in the terminal:
xxxxxxxxxxsudo nano /etc/systemd/system/jupyter.service
Add the following content to the file:
xxxxxxxxxx[Unit]Description=Jupyter LabAfter=network.target[Service]Type=simpleExecStart=/usr/local/bin/jupyter-labconfig=/home/pi/.jupyter/jupyter_lab_config.py --no-browserUser=piGroup=piWorkingDirectory=/home/piRestart=alwaysRestartSec=10[Install]WantedBy=multi-user.target
pi: My current system's username
ExecStart: Command to start Jupyter Lab. Modify to the JupyterLab installation path and configuration file path (if you followed all the steps as instructed, you can enter the same path):
xxxxxxxxxxView Jupyter-lab installation path: which jupyter-labConfiguration file path reference the path generated above
WorkingDirectory: Jupyter-lab's working directory, can be changed as needed.

jupyter.service service:
Enable auto-start on boot:
xxxxxxxxxxsudo systemctl enable jupyter
Disable auto-start on boot:
xxxxxxxxxxsudo systemctl disable jupyter
Start service:
xxxxxxxxxxsudo systemctl start jupyter
Stop service:
xxxxxxxxxxsudo systemctl stop jupyter
Check service status:
xxxxxxxxxxsudo systemctl status jupyter
After entering the commands to enable jupyter.service auto-start and start the service in the terminal, restart the Raspberry Pi system.

After completing the above steps, you can access via LAN without entering jupyter lab in the terminal!