首页 > 其他分享 >项目集成jupyter

项目集成jupyter

时间:2022-12-02 10:47:05浏览次数:39  
标签:集成 ServerApp jupyter 项目 config lab NotebookApp True

1运行 jupyter notebook --generate-config
生成配置文件
修改跨域访问设置
c.NotebookApp.tornado_settings = {
'headers': {
'Content-Security-Policy': "frame-ancestors self ; report-uri /api/security/csp-report",
}
}
c.NotebookApp.allow_origin = '
'
Xsrf 设置
c.NotebookApp.disable_check_xsrf = True

注意配置前面都不能有空格顶行写

端口

c.NotebookApp.port = 9820

IP

c.NotebookApp.ip = '0.0.0.0'

工作目录

c.NotebookApp.notebook_dir = '/jupyter/'
设置在启动后不自动打开浏览器
c.ServerApp.open_browser = False

root启动运行 不是则不需要打开

c.NotebookApp.allow_root = True

c.ServerApp.token = ''

jupyter lab --generate-config

lab 工作空间 配置这个

c.ServerApp.root_dir = ''
c.ServerApp.token = ''

修改跨域访问设置
c.ServerApp.tornado_settings = {
'headers': {
'Content-Security-Policy': "frame-ancestors self *; report-uri /api/security/csp-report",
}
}

在配置文件目录下增加custom\ custom.js
内容如下
define(['base/js/namespace'], function(Jupyter){
Jupyter._target = '_self';
});

jupyter lab启动

linux后台启动
nohup /opt/pyenvs/envtf22/bin/jupyter-lab --config='./jupyter/jupyter_notebook_config.py' &>./jupyter_lab_log.txt &

不再设置密码
最终配置如下

Configuration file for jupyter-notebook.

c = get_config() # noqa

c.ServerApp.allow_origin = '0.0.0.0'

c.ServerApp.disable_check_xsrf = True
c.LabApp.disable_check_xsrf = True

默认工作目录

c.ServerApp.notebook_dir = 'D:\jupyterWkps'

默认不打开浏览器

c.ServerApp.open_browser = False

c.ServerApp.token = ''

c.ServerApp.tornado_settings = {
'headers': {
'Content-Security-Policy': "frame-ancestors * 'self' ",
}
}

允许远程登录

c.ServerApp.allow_remote_access = True

这里没设置密码和跨域,会出现未授权访问漏洞,自己注意

标签:集成,ServerApp,jupyter,项目,config,lab,NotebookApp,True
From: https://www.cnblogs.com/rainbow--/p/16943677.html

相关文章