安装Jupyter Lab
Jupyter Notebook是基于网页的用于交互计算的应用程序。其可被应用于全过程计算:开发、文档编写、运行代码和展示结果

Jupyter Notebook是基于网页的用于交互计算的应用程序。其可被应用于全过程计算:开发、文档编写、运行代码和展示结果。深度学习时,很多教学都是使用Jupyter Notebook。

安装

conda

conda install -c conda-forge jupyterlab

mamba

mamba install -c conda-forge jupyterlab

pip

pip install jupyterlab

配置

生成配置文件

jupyter-lab --generate-config

设置密码

方式一

jupyter-lab password

方式二

ipython环境执行下面命令:

➜  ipython
Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from notebook.auth import passwd

In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$rE0pUX21r5hprm76ZFAf8g$m9KHHM9jLCx6mTwBHSwXT3CtSo97OQxFGMiqgthktfE'

修改 ~/.jupyter/jupyter_lab_config.py 文件的password,为上面的密码

c.ServerApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$rE0pUX21r5hprm76ZFAf8g$m9KHHM9jLCx6mTwBHSwXT3CtSo97OQxFGMiqgthktfE'

允许外部访问

c.ServerApp.ip = '*'

开机启动

在/lib/systemd/system 目录创建文件 jupyter-lab.service,写如下内容:

[Unit]
Description=Jupyter Lab

[Service]
Type=simple
PIDFile=/run/jupyter.pid
ExecStart=/home/yearnfar/.local/bin/jupyter-lab --config=/home/yearnfar/.jupyter/jupyter_lab_config.py
User=yearnfar
Group=yearnfar
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
# 开机自动启动
systemctl enable jupyter-lab

# 关闭开机自动启动
systemctl disable jupyter-lab

# 开启服务
systemctl start jupyter-lab

# 停止服务
systemctl stop jupyter-lab

最后修改于 2022-11-20

此篇文章的评论功能已经停用。