Jupyter Notebook:由于Websocket连接失败,因此没有与服务器的连接 [英] Jupyter notebook: No connection to server because websocket connection fails

查看:1616
本文介绍了Jupyter Notebook:由于Websocket连接失败,因此没有与服务器的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在Windows 10中通过点子安装了Jupyter(Python版本是3.7.2),通过调用jupyter notebook启动了jupyter服务器,在我的Web浏览器中创建了一个带有内核python3的新笔记本,但是与内核的连接是从未实现.

I have just installed Jupyter over pip (Python version is 3.7.2) in Windows 10, started the jupyter server by calling jupyter notebook, created a new notebook with kernel python3 in my web browser but a connection to the kernel is never achieved.

在命令行中没有明显的错误:

No obvious error in the command line:

C:\Users\xxxx>jupyter notebook
[I 21:18:21.005 NotebookApp] Serving notebooks from local directory: C:\Users\xxxx
[I 21:18:21.005 NotebookApp] The Jupyter Notebook is running at:
[I 21:18:21.006 NotebookApp] http://localhost:8888/?token=5743fcbbc805efa4b36c983a7beb63b95cf922957378d64f
[I 21:18:21.007 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 21:18:21.087 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/xxxx/AppData/Roaming/jupyter/runtime/nbserver-18416-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=5743fcbbc805efa4b36c983a7beb63b95cf922957378d64f
[I 21:18:33.777 NotebookApp] Creating new notebook in
[I 21:18:35.512 NotebookApp] Kernel started: ab30c1b3-55d2-45e9-9f01-b4bfc077bb01
[I 21:18:36.883 NotebookApp] Adapting to protocol v5.1 for kernel ab30c1b3-55d2-45e9-9f01-b4bfc077bb01
c:\users\xxxx\appdata\local\programs\python\python37-32\lib\site-packages\notebook\base\zmqhandlers.py:284: RuntimeWarning: coroutine 'WebSocketHandler.get' was never awaited
  super(AuthenticatedZMQStreamHandler, self).get(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
[W 21:18:37.912 NotebookApp] Replacing stale connection: ab30c1b3-55d2-45e9-9f01-b4bfc077bb01:397de5420f9e4bce82d95967bf5fa1eb
[W 21:19:14.026 NotebookApp] 404 GET /static/components/preact/preact.min.js.map (::1) 18.98ms referer=None
[W 21:19:14.040 NotebookApp] 404 GET /static/components/preact-compat/preact-compat.min.js.map (::1) 6.49ms referer=None
[W 21:19:14.050 NotebookApp] 404 GET /static/components/proptypes/index.js.map (::1) 15.99ms referer=None
[I 21:20:36.067 NotebookApp] Saving file at /Untitled1.ipynb
[W 21:22:40.052 NotebookApp] Replacing stale connection: ab30c1b3-55d2-45e9-9f01-b4bfc077bb01:397de5420f9e4bce82d95967bf5fa1eb

我尝试了所有Chrome,Firefox和Microsoft Edge,但均未成功.我什至尝试了PyCharm.

I have tried all Chrome, Firefox and Microsoft Edge with no success. I even tried through PyCharm.

然后我查看了浏览器的js控制台,看来问题出在websocket连接失败:

I then looked at the js console of the browser and seems that the problem is a failure in the websocket connection:

menubar.js:277 actions jupyter-notebook:find-and-replace does not exist, still binding it in case it will be defined later...
MenuBar.bind_events @ menubar.js:277
utils.js:60 load_extensions Arguments(1)
bidi.js:19 Loaded moment locale en
utils.js:37 Loading extension: jupyter-js-widgets/extension
session.js:54 Session: kernel_created (003a523b-3d40-41ac-b65e-154db92d5528)
kernel.js:459 Starting WebSockets: ws://localhost:8888/api/kernels/f8809bf9-988f-4666-b183-e01bed63fa76
kernel.js:461 WebSocket connection to 'ws://localhost:8888/api/kernels/f8809bf9-988f-4666-b183-e01bed63fa76/channels?session_id=e49c21f065e64e7a89847a0859d689dd' failed: Error during WebSocket handshake: Unexpected response code: 200
Kernel.start_channels @ kernel.js:461
kernel.js:103 Kernel: kernel_disconnected (f8809bf9-988f-4666-b183-e01bed63fa76)
kernel.js:544 WebSocket connection failed:  ws://localhost:8888/api/kernels/f8809bf9-988f-4666-b183-e01bed63fa76 true
kernel.js:562 Connection lost, reconnecting in 1 seconds.
kernel.js:103 Kernel: kernel_reconnecting (f8809bf9-988f-4666-b183-e01bed63fa76)
kernel.js:459 Starting WebSockets: ws://localhost:8888/api/kernels/f8809bf9-988f-4666-b183-e01bed63fa76

这可能是什么原因?

推荐答案

我遇到了同样的问题,并遵循此vvk2001github https://github.com/jupyter/notebook/issues/4399 为我修复了它.

I had the same problem, and following this vvk2001github https://github.com/jupyter/notebook/issues/4399 fixed it for me.

卸载龙卷风6并重新安装龙卷风5.

Uninstall tornado 6 and reinstall tornado 5.

sudo pip3 uninstall tornado
sudo pip3 install tornado==5.1.1

@kaleo也对@Jason Nichols的类似问题给出了答案

@kaleo gave this answer as well to similar question from @Jason Nichols

这篇关于Jupyter Notebook:由于Websocket连接失败,因此没有与服务器的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆