Jupyter Notebook:由于Websocket连接失败,因此无法连接到服务器

尼克:

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

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

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。

然后,我查看了浏览器的js控制台,似乎问题是websocket连接失败:

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

这可能是什么原因?

NicoWheat:

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

卸载龙卷风6,然后重新安装龙卷风5。

sudo pip3 uninstall tornado
sudo pip3 install tornado==5.1.1

@kaleo给出了这个答案以及@Jason Nichols的类似问题

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法连接到Docker服务的Jupyter Notebook

无法从 Windows 10 连接到 jupyter notebook ec2 服务器

Java 内核无法连接到 jupyter notebook

使用 Jupyter Notebook 通过指定的螺栓连接连接到服务器图形数据库

错误:(jupyter服务器崩溃。无法连接。来自jupyter的错误代码:1)

AWS上的Jupyter Notebook无法连接到内核

无法在Windows 10中连接到Tensorflow Jupyter Notebook

如何在AWS- Ubuntu上连接Jupyter Notebook远程服务器

在 Jupyter Lab notebook 中使用 PyMongo 不会关闭与 MongoDB 服务器的任何连接

如何连接到远程Jupyter笔记本服务器?

由于Google Colab,在VS Code上使用Jupyter Notebook时无法连接到内核。它已卸载,但仍无法连接到内核

无法退出正在运行的Jupyter Notebook服务器

无法在AWS上连接Jupyter Notebook

更改Jupyter Notebook服务器密码

如何将Jupyter Notebook连接到Spyder内核?

如何在Watson Studio中从Jupyter Notebook连接到DashDB?

如何使用Visual Studio 2017连接到Jupyter Notebook

如何将Jupyter Ipython Notebook连接到Amazon Redshift

使用Jupyter Notebook连接到Amazon Web Serives

如何连接到现有的Jupyter Notebook内核并使用变量浏览器检查变量?

无法停止 Jupyter Notebook

无法启动Jupyter Notebook

虚拟环境下无法通过 Jupyter Notebook 连接 Python

Visual Studio Code的新功能可以连接到Jupyter Notebook,也可以连接到JupyterHub吗?

在Jupyter Notebook中运行Tornado服务器

在Jupyter Notebook中调试Flask服务器

从远程服务器永久使用Jupyter Notebook

Jupyter Notebook:500 内部服务器错误

从 Jupyter notebook 访问本地 Postgresql 服务器