【问题标题】:Error while trying to run ipython3 notebook server on Ubuntu尝试在 Ubuntu 上运行 ipython3 笔记本服务器时出错
【发布时间】:2015-07-31 18:04:15
【问题描述】:

我按照instructions 设置了 ipython3 服务器。

这是我的ipython_notebook_config.py:

c.NotebookApp.ip = '*'
c.NotebookApp.certfile = u'/home/ed/.ipython/profile_default/ds.pem'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha512:..mykey...'
c.NotebookApp.port = 20000

当我启动笔记本时,我得到了:

ipython3 notebook                                                                                 ~
[I 19:51:50.443 NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
[I 19:51:50.476 NotebookApp] Serving notebooks from local directory: /home/ed
[I 19:51:50.476 NotebookApp] 0 active kernels 
[I 19:51:50.476 NotebookApp] The IPython Notebook is running at: https://[all ip addresses on your system]:20000/
[I 19:51:50.476 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation)

当我尝试从外部连接到这台机器时出现错误:

[E 19:52:02.413 NotebookApp] Exception in callback (<socket.socket fd=5, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('0.0.0.0', 20000)>, <function wrap.<locals>.null_wrapper at 0x7f766269a488>)
    Traceback (most recent call last):
      File "/home/ed/.local/lib/python3.4/site-packages/tornado/ioloop.py", line 866, in start
        handler_func(fd_obj, events)
      File "/home/ed/.local/lib/python3.4/site-packages/tornado/stack_context.py", line 275, in null_wrapper
        return fn(*args, **kwargs)
      File "/home/ed/.local/lib/python3.4/site-packages/tornado/netutil.py", line 265, in accept_handler
        callback(connection, address)
      File "/home/ed/.local/lib/python3.4/site-packages/tornado/tcpserver.py", line 239, in _handle_connection
        do_handshake_on_connect=False)
      File "/home/ed/.local/lib/python3.4/site-packages/tornado/netutil.py", line 501, in ssl_wrap_socket
        context = ssl_options_to_context(ssl_options)
      File "/home/ed/.local/lib/python3.4/site-packages/tornado/netutil.py", line 478, in ssl_options_to_context
        context.load_cert_chain(ssl_options['certfile'], ssl_options.get('keyfile', None))
    ssl.SSLError: [SSL] PEM lib (_ssl.c:2536)

我已经在另外两台机器上设置了这个,我没有遇到任何问题。我不知道出了什么问题,可能是缺少库或一些我看不到的字幕错误。

我在 Ubuntu 15.04 上使用 IPython 3.2.1.、Python 3.4.3。

有什么想法吗?

【问题讨论】:

  • 似乎是一个 ssl 错误,您应该检查证书和密钥

标签: ipython ipython-notebook jupyter


【解决方案1】:

使用修改后的 opessl 命令

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.key -out mycert.pem

来自@GeQi 并确保在浏览器中使用 HTTPS 对我有用。

【讨论】:

    【解决方案2】:

    检查 1:更新 AWS EC2 安全组中 22、443、8888 的入站规则。

    检查 2:确保使用以下命令在 certs 文件夹中创建 mycert.pem 文件:

    $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.pem -out mycert.pem

    检查 3:passwd() > 保存 SHA 密钥并将该密钥添加到 jupyter_notebook_config.py

    检查 4:使用https://public-DNS-of-EC2-Instance:8888 如果连接不是私有的,则继续高级...

    更多详情: https://github.com/prakashpy/miscellaneous/tree/master/jupyter-notebook-on-aws-ec2

    【讨论】:

      【解决方案3】:

      Jupyter 和 IPython 的未来

      IPython 是一个不断发展的项目,具有越来越多与语言无关的组件。 IPython 3.x 是 IPython 的最后一个单一版本,包含笔记本服务器、qtconsole 等。从 IPython 4.0 开始,项目的语言无关部分:笔记本格式、消息协议、qtconsole、笔记本 Web 应用程序等。已经转移到名为 Jupyter 的新项目中。 IPython 本身专注于交互式 Python,其中一部分是为 Jupyter 提供 Python 内核。

      简而言之,notebook 不再是 IPython 项目的一部分,因此您应该寻找“Jupyter notebook”的关键字。切换到较新的 Jupyter notebook 相当容易,只需按照文档(来自here 或here)安装模块和set up the public server。程序几乎相同。但是,在完成所有这些后,我仍然遇到相同的 SSLError。我在 github repo 中找到了解决方案 here:

      在对 openssl 参数进行轻微更改后,它对我有用。我将密钥和证书都保存在同一个文件“mycert.pem”中。 原文:$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.key -out mycert.pem 我的版本:$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mycert.pem -out mycert.pem

      有些人报告说这对他们来说行不通,而且问题还没有解决,尽管这对我来说非常有效。此外,您可能需要清理以前的配置。

      # remove the earlier created ipython profile
      $ ipython profile locate nbserver
      /home/ubuntu/.ipython/profile_nbserver
      $ rm -r /home/ubuntu/.ipython/profile_nbserver
      $ ipython profile locate nbserver
      [ProfileLocate] CRITICAL | Profile 'nbserver' not found.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-28
        相关资源
        最近更新 更多