Jupyter Lab安装与使用

JupyterLab 官网:

https://jupyterlab.readthedocs.io

pip 安装:

1
pip install jupyterlab

生成配置文件:

1
2
# 默认配置文件生成路径:~/.jupyter/jupyter_lab_config.py
jupyter lab --generate-config

生成密码:

1
2
3
jupyter lad password
# 输入两次密码生成文件:~/.jupyter/jupyter_server_config.json
# 复制文件中password的加密字符添加到jupyter_lab_config.py配置中

修改配置:

jupyter_lab_config.py中添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 开放ip(远程访问)
c.LabApp.ip='*'
# 开放端口
c.LabApp.port =8888
# 密码加密字符(填入上面生成的加密字符)
c.LabApp.password = 'argon2:xxxxxxxxxxxxxx'
# 关闭启动自动打开网页jupyter
c.LabApp.open_browser = False
# 指定jupyter lab工作目录
c.LabApp.notebook_dir = '/home/xxx/jupyter_work'
# 允许远程连接(远程访问)
c.LabApp.allow_remote_access = True
# 允许用户以root身份运行服务器
c.LabApp.allow_root = True

安装插件:

1
2
3
4
# 安装中文插件(网页中修改 Settings->Language->Chinese (simplified, china))
pip install jupyterlab-language-pack-zh-CN

# 其他插件可以直接在jupyter网页面板中查看/安装

启动:

1
nohup jupyter lab &

停止:

1.网页面板中点击 File->Shut Down
2.shell 命令

1
2
3
4
# 查看jupyter进程
ps -ef|grep jupyter
# 关闭jupyter进程
kill -quit 进程ID

注意:

pip安装可能会有环境变量问题找不到jupyter lab
添加环境变量:
sudo vim ~/.bashrc
export PATH="$HOME/.local/bin:$PATH"
source ~/.bashrc