Linux系统中配置jupyter lab环境
-
安装jupyter lab,执行命令
pip install jupyterlab
; -
生成配置文件,执行命令
jupyter lab --generate-config
,配置文目录/root/.jupyter/jupyter_lab_config.py
; -
修改配置文件:
-
配置允许访问的IP,*代表所有IP均可访问:
c.ServerApp.ip= '*'
-
配置jupyter lab运行端口:
c.ServerApp.port=23
-
启动时是否打开浏览器:
c.ServerApp.open_browser=False
-
文件夹根路径(需手动创建目录):
c.ServerApp.root_dir='/root/code'
-
设置是否需要密码:
c.ServerApp.password_required=False
-
设置连接时的token,此时表示不需要token:
c.ServerApp.token=''
-
需要密码时设置密码:
c.ServerApp.password='xxxxxxx'
-
允许跨域访问:
c.ServerApp.tornado_settings={'headers':{'Content-Security-Policy':"frame-ancestors self *"}}
-
-
启动jupyter服务,执行命令
jupyter lab –no-browser –allow-root
。利用pm2后台启动,执行命令pm2 start 'jupyter lab --no-browser --allow-root' -n 'jupyter
-
待服务启动后,可根据服务器IP地址
:
端口号的形式访问jupyter lab。