1. Install jupyterlab in the server virtual environment
conda activate xxx
pip install jupyterlab
2. Configure jupyterlab
(1) Generate jupyterlab configuration file
jupyter notebook --generate-config
# 显示
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
(2) Set password
jupyter notebook password
# 显示
Enter password: 输入密码
Verify password: 再次输入密码进行确认
# 最终显示
[NotebookPasswordApp] Wrote hashed password to /root/.jupyter/jupyter_notebook_config.json
3. Start jupyterlab on the server side
(1) Install ipykernel
pip install ipykernel
(2) Write the environment into the kernel of jupyterlab
python -m ipykernel install --user --name 环境名称 --display-name "显示的名称"
# 例:
# python -m ipykernel install --user --name xxx --display-name "xxx_jupyterlab"
After starting jupyter-lab, all packages installed in this xxx environment can be used.
(3) Enter your own folder
cd 目标文件夹
(4) Start jupyterlab
Start jupyter-lab command (ip cannot be changed, port can be changed):
jupyter-lab --ip 0.0.0.0 --port 8888 --no-browser --allow-root
Then open a local browser and enter: ip address:port number. The IP address here refers to the ip address of your server (on which server you started jupyter-lab). The port number is the port number specified when starting jupyter-lab. Here to 8888.
4. Start jupyterlab on the web page
After opening the browser on your local computer, enter in the address bar:
服务器IP:8888
Just enter the password you set in step 2-2 and jump to the web version of jupyterlab.
If there are files in your directory, they will all be displayed on the left. Double-click the code file to debug and run it!
5. Close jupyterlab service
Use the shortcut key ctrl+C on the console and enter y to confirm.