【问题标题】:Jupyter and IPython Kernel fails to start on RHEL 7.6Jupyter 和 IPython 内核无法在 RHEL 7.6 上启动
【发布时间】:2019-08-06 18:52:06
【问题描述】:

我被卡住了...我正在尝试在新建的企业 Linux 机器上设置 Jupyter 服务器。我有 Miniconda 和 Anaconda 路线,使用 Python 3.7 和 3.6。我尝试使用 pip 和 conda 分别安装和重新安装 Jupyter / IPython。

不可避免地,基于浏览器的 Jupyter notebook 无法执行任何代码,它卡在In [*] 状态。这表明内核出现故障。

确实,

$ jupyter console --debug
[ZMQTerminalIPythonApp] Searching ['/home/scadmin', '/home/scadmin/.jupyter', '/opt/conda/a3/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[ZMQTerminalIPythonApp] Looking for jupyter_config in /etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /usr/local/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /opt/conda/a3/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /home/scadmin/.jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_config in /home/scadmin
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /usr/local/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /opt/conda/a3/etc/jupyter
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /home/scadmin/.jupyter
[ZMQTerminalIPythonApp] Loaded config file: /home/scadmin/.jupyter/jupyter_console_config.py
[ZMQTerminalIPythonApp] Looking for jupyter_console_config in /home/scadmin
[ZMQTerminalIPythonApp] Connection File not found: /run/user/1008/jupyter/kernel-19936.json
[ZMQTerminalIPythonApp] Starting kernel: ['/opt/conda/a3/bin/python', '-m', 'ipykernel_launcher', '-f', '/run/user/1008/jupyter/kernel-19936.json']
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:47202
[ZMQTerminalIPythonApp] connecting shell channel to tcp://127.0.0.1:47589
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:47589
[ZMQTerminalIPythonApp] connecting iopub channel to tcp://127.0.0.1:42874
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:42874
[ZMQTerminalIPythonApp] connecting stdin channel to tcp://127.0.0.1:32777
[ZMQTerminalIPythonApp] Connecting to: tcp://127.0.0.1:32777
[ZMQTerminalIPythonApp] connecting heartbeat channel to tcp://127.0.0.1:44354
Traceback (most recent call last):
  File "/opt/conda/a3/lib/python3.7/site-packages/jupyter_console/ptshell.py", line 341, in init_kernel_info
    reply = self.client.get_shell_msg(timeout=1)
  File "/opt/conda/a3/lib/python3.7/site-packages/jupyter_client/client.py", line 77, in get_shell_msg
    return self.shell_channel.get_msg(*args, **kwargs)
  File "/opt/conda/a3/lib/python3.7/site-packages/jupyter_client/blocking/channels.py", line 57, in get_msg
    raise Empty
_queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/a3/bin/jupyter-console", line 11, in <module>
    sys.exit(main())
  File "/opt/conda/a3/lib/python3.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/opt/conda/a3/lib/python3.7/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-116>", line 2, in initialize
  File "/opt/conda/a3/lib/python3.7/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/conda/a3/lib/python3.7/site-packages/jupyter_console/app.py", line 142, in initialize
    self.init_shell()
  File "/opt/conda/a3/lib/python3.7/site-packages/jupyter_console/app.py", line 115, in init_shell
    confirm_exit=self.confirm_exit,
  File "/opt/conda/a3/lib/python3.7/site-packages/traitlets/config/configurable.py", line 412, in instance
    inst = cls(*args, **kwargs)
  File "/opt/conda/a3/lib/python3.7/site-packages/jupyter_console/ptshell.py", line 287, in __init__
    self.init_kernel_info()
  File "/opt/conda/a3/lib/python3.7/site-packages/jupyter_console/ptshell.py", line 344, in init_kernel_info
    raise RuntimeError("Kernel didn't respond to kernel_info_request")
RuntimeError: Kernel didn't respond to kernel_info_request
$ [IPKernelApp] WARNING | Parent appears to have exited, shutting down.

任何帮助和想法将不胜感激......

【问题讨论】:

  • 你在哪里安装了 Jupyter?您是否还在该环境中安装了nb_conda_kernels? Anaconda 和 Miniconda 是不必要的。使用 Miniconda 并为您需要的任何其他 Python 版本制作环境。
  • 这个特定的例子是基础环境,在全新安装 anaconda 之后,所有内容都在 /opt/conda/a3 中。我的意思是 anaconda 或 miniconda,而不是 AND :)
  • 安装 nb_conda_kernels 没有帮助。

标签: jupyter-notebook ipython conda rhel7


【解决方案1】:

归结为防火墙策略默认丢弃 TCP 流量,指定端口除外。

将其添加到 /etc/sysconfig/iptables 后跟 systemctl restart iptables 解决了该问题。

-A INPUT -p tcp -m tcp -s localhost --dport 32768:65535 -m state --state NEW -m comment --comment "Jupyter ZeroMQ" -j ACCEPT

请注意Jupyter documentation asks for port range 49152:65535 for the ZeroMQ communication。事实上,它选择的端口范围更广,因此从 32768 开始。

【讨论】:

    猜你喜欢
    • 2018-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-24
    • 1970-01-01
    • 2022-11-02
    • 1970-01-01
    相关资源
    最近更新 更多