92. jupyter 安装与使用

配置文件

  1. 生成配置文件: jupyter lab --generate-config, 这将会生成一个 jupyter_lab_config.py 的配置文件到 ./jupyter 文件夹下, 后续需进行编辑

外网访问

配置文件

1
2
3
4
5
6
7
c.ServerApp.allow_remote_access = True  # 允许使用远程访问
c.ServerApp.allow_root = True # 允许使用root
c.ServerApp.ip = '0.0.0.0' # 监听所有ip, default: localhost
c.ServerApp.open_browser = False # 服务器端默认启动jupyter时不自动打开浏览器
c.ServerApp.port = 8888 # 服务器端口号,可自行设置
c.ServerApp.root_dir = '/root' # 设置 Jupyter Lab 工作目录
c.LabApp.notebook_dir = '/root' # 设置 Jupyter Lab 的启动目录

端口转发

  1. 连接服务器, 并设置将 jupyter port 转发到本地端口: ssh -L 8889:127.0.0.1:8888 username@ip

    该命令将服务器端的 8888 端口映射到本地 8889

  2. 打开网址: 127.0.0.1:8889