项目集成jupyter

1运行
shell 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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值