项目集成jupyter

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

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


__EOF__

本文作者华哥哥
本文链接https://www.cnblogs.com/rainbow--/p/16943677.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   小秦的开发梦  阅读(467)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示