简体   繁体   English

家庭 Ubuntu 服务器上的 Jupyter Notebook 配置:kernel 未连接

[英]Configuration for Jupyter Notebook on a home Ubuntu server: kernel is not connecting

I set up an Ubuntu server to host a Jupyter Notebook that I can access from the web.我设置了一个 Ubuntu 服务器来托管一个 Jupyter Notebook,我可以从 web 访问它。 Everything seems to work but whenever I open the notebook, the Python Kernel is stuck and it does not connect:一切似乎都正常,但每当我打开笔记本时,Python Kernel 就会卡住并且无法连接:

在此处输入图像描述

In the terminal, with the current configuration it does not report warnings or errors:在终端中,使用当前配置它不会报告警告或错误:

在此处输入图像描述

but I have tried many similar configurations and sometimes, when the kernel tried to connect, it was showing warnings like:但我尝试了许多类似的配置,有时,当 kernel 尝试连接时,它会显示如下警告:

  • [W 01:51:26.202 NotebookApp] 400 GET /api/kernels/aa45474d-7fb8-4685-98dc-5ebeba378f41/channels? [W 01:51:26.202 NotebookApp] 400 GET /api/kernels/aa45474d-7fb8-4685-98dc-5ebeba378f41/channels?
  • [W 16:06:07.386 NotebookApp] 403 GET /api/kernels/f589fe39-b21c-4eb1-9543-dcf2b9c5881d/channels? [W 16:06:07.386 NotebookApp] 403 GET /api/kernels/f589fe39-b21c-4eb1-9543-dcf2b9c5881d/channels?

I have found various similar issues online and they usually point to either the Jupyter configuration or the Apache/nginx configuration, however I have tried many of the proposed configurations and none of them solved my problem.我在网上发现了各种类似的问题,它们通常指向 Jupyter 配置或 Apache/nginx 配置,但是我尝试了许多建议的配置,但都没有解决我的问题。 I cannot exclude the problem is somewhere else.我不能排除问题出在其他地方。

jupyter_notebook_config.py: jupyter_notebook_config.py: 在此处输入图像描述 Notice that I have commented out the references to the certificate, if I don't, then the notebook browser will give a "proxy error" and it won't load.请注意,我已经注释掉了对证书的引用,如果我不这样做,那么笔记本浏览器将给出“代理错误”并且它不会加载。 However, the certificate is loaded in the apache configuration and seems to work fine there.但是,证书是在 apache 配置中加载的,并且在那里似乎可以正常工作。 Is it necessary to have it loaded here as well?是否也需要在这里加载它?

apache configuration: apache配置: 在此处输入图像描述 Commented out are some of the many lines I tried to add following suggestions from other pages.注释掉的是我试图从其他页面添加以下建议的许多行中的一些。 Any help will be really welcome, I have been stuck on this for one week now.任何帮助都会非常受欢迎,我已经坚持了一个星期了。

After a full day of attempts I found a solution.经过一整天的尝试,我找到了解决方案。

  1. In the notebook configuration I uncommented the certificate lines.在笔记本配置中,我取消了证书行的注释。

  2. In the apache configuration I added:在 apache 配置中我添加了:

    SSLProxyEngine On SSLProxyEngine 开启

  3. I have changed the reverse proxy lines using https:我已经使用 https 更改了反向代理行:

    ProxyPass https://localhost:5000/notebook ProxyPass https://localhost:5000/notebook

    ProxyPassReverse https://localhost:5000/notebook ProxyPassReverse https://localhost:5000/notebook

  4. I removed the authentication lines:我删除了身份验证行:

    AuthName "Please login" AuthName "请登录"

    AuthType basic AuthType 基本

    AuthBasicProvider file AuthBasicProvider 文件

    AuthUserFile "/home/pomi/auth_file_name" AuthUserFile "/home/pomi/auth_file_name"

    Require valid-user需要有效用户

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM