Jupyter Lab environment construction

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.

1. Install Jupyter Lab

Enter the command in the terminal:

Update the repository list and software before installing the software:

image-20231219092847141

Install Jupyter Lab in a Python 3 environment and enter the command in the terminal:

If the download fails multiple times, you can specify the Python software package mirror address of Tsinghua University to speed up domestic downloads:

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.

image-20231219092934618

The following prompt appears indicating that the installation is successful.

image-20231219093134630

2. Open Jupyter Lab

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!

image-20231219093240323

3. Set up LAN to access jupyter lab

The generated configuration file path is the path to the file that will be modified later.

image-20231219093815761

Press Ctrl+X, enter Y, then press Enter to save and exit editing!

image-20231219093611969

4. Set up access to jupyter lab

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.

image-20231219093836941

Restart the Raspberry Pi after setting the password!

Devices on the same LAN can enter IP:8888 in the browser to access!

image-20231214100852796

5. Set jupyter lab to start automatically after booting

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.

Enter the following command in the terminal:

Add the following content to the file:

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)

WorkingDirectory: The working directory of Jupyter-lab, which can be changed by yourself

image-20231219094041289

Enable auto-start at boot

Disable auto-start at boot

Start service

Out of service

Check service status

Enter the enable jupyter.service service self-start and start service commands in the terminal and then restart the Raspberry Pi system.

image-20231219094203536

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