安装Jupyter Lab
pip3 install jupyterlab
生成配置文件
jupyter lab --generate-config
在配置文件中追加下面内容
c.NotebookApp.allow_remote_access = True
c.NotebookApp.open_browser = False
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8888
c.NotebookApp.password = '加密密码字符串'
加密密码字符串可以通过Python命令获得
from jupyter_server.auth import passwd
passwd()
手动启动Jupyter Lab
jupyter lab
此时浏览器打开http://ip:8888/lab就可以了
接下来配置自动启动
vim /etc/systemd/system/jupyterlab.service
写入以下内容
[Unit]
Description=JupyterLab
After=network.target
[Service]
Type=simple
PIDFile=/run/jupyterlab.pid
ExecStart=/usr/local/bin/jupyter lab --allow-root
User=root
WorkingDirectory=/home
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
接下来使开机启动生效
systemctl enable jupyterlab.service
systemctl start jupyterlab.service
查看启动结果
systemctl status jupyterlab.service
最后reboot一下,如果重启之后可以浏览器访问,就是成功了
参考文章:https://blog.csdn.net/weixin_53742691/article/details/138424057