Jupyter Lab environment construction

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 other data science tasks.

Note: The factory image has already installed this environment, so there is no need to install it again. Just learn how to build it

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 the Python 3 environment and enter the command in the terminal:

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

If you directly enter the Jupyter Lab installation command in the terminal, an error "error: externally-managed-environment" will appear. You can use the following command to solve it: The python version is modified according to the version of your system. My current system version is 3.11

image-20231219092934618

The following prompt indicates that the installation is successful.

image-20231219093134630

2. Open Jupyter Lab

Input jupyter lab in the terminal. If a password is required, you can set the password according to the fourth step of the tutorial before using it!

image-20231219093240323

3. Set up LAN access to jupyter lab

The generated configuration file path is the path to modify the file later

image-20231219093815761

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

image-20231219093611969

4. Set up access to jupyter lab

Enter the command to set the password in the terminal. You need to enter it twice. The input content will not be displayed after entering the password

image-20231219093836941

Restart the Raspberry Pi after setting the password!

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

image-20231214100852796

5. Set Jupyter Lab to start automatically

After completing the above steps, you need to enter the command in the terminal each time you use Juypter Lab. For more convenient use, we can configure Jupyter Lab to start automatically.

Enter the following command in the terminal:

Add the following content to the file:

pi: my current system user name

ExecStart: command to start Jupyter lab, change to JupyterLab installation path and configuration file path (if the steps are all in accordance with our operation, then enter the same path)

WorkingDirectory: Jupyter-lab's working directory, which can be changed at your own discretion

image-20231219094041289

Enable automatic startup

Disable automatic startup

Start the service

Stop the service

Check the service status

Enter the command to enable the jupyter.service service to start automatically and restart the Raspberry Pi system.

image-20231219094203536

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