jupyter notebook打开后一直显示connecting to kernel该怎么解决?

新手上路,请多包涵

jupyter notebook打开后一直显示connecting to kernel如图中黄色字体所示
cmd界面如下:
[I 20:26:19.826 NotebookApp] JupyterLab extension loaded from E:\anaconda\lib\site-packages\jupyterlab
[I 20:26:19.826 NotebookApp] JupyterLab application directory is E:\anaconda\share\jupyter\lab
[I 20:26:19.828 NotebookApp] Serving notebooks from local directory: C:\Users\86152
[I 20:26:19.828 NotebookApp] The Jupyter Notebook is running at:
[I 20:26:19.828 NotebookApp] http://localhost:8888/?token=25ccc4964d3943ed413968ce0a295c0b...
[I 20:26:19.828 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 20:26:19.851 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
    http://localhost:8888/?token=25ccc4964d3943ed413968ce0a295c0bd06f35443bb265cf

[I 20:26:20.028 NotebookApp] Accepting one-time-token-authenticated connection from ::1
E:\anaconda\lib\json\encoder.py:257: UserWarning: date_default is deprecated since jupyter_client 7.0.0. Use jupyter_client.jsonutil.json_default.
return _iterencode(o, 0)
[I 20:26:41.323 NotebookApp] Creating new notebook in
E:\anaconda\lib\json\encoder.py:257: UserWarning: date_default is deprecated since jupyter_client 7.0.0. Use jupyter_client.jsonutil.json_default.
return _iterencode(o, 0)
[I 20:26:42.441 NotebookApp] Kernel started: 426c41b4-1f1d-4aa8-8986-252f95f398e8
[I 20:26:42.970 NotebookApp] Adapting to protocol v5.1 for kernel 426c41b4-1f1d-4aa8-8986-252f95f398e8
E:\anaconda\lib\site-packages\notebook\base\zmqhandlers.py:284: RuntimeWarning: coroutine 'WebSocketHandler.get' was never awaited
super(AuthenticatedZMQStreamHandler, self).get(args, *kwargs)
[W 20:26:43.977 NotebookApp] Replacing stale connection: 426c41b4-1f1d-4aa8-8986-252f95f398e8:88c31101a6c240db839ef123718400b0
[I 20:28:43.201 NotebookApp] Saving file at /Untitled20.ipynb
E:\anaconda\lib\site-packages\nbformat\__init__.py:129: MissingIDFieldWarning: Code cell is missing an id field, this will become a hard error in future nbformat versions. You may want to use normalize() on your notebooks before validations (available since nbformat 5.1.4). Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
validate(nb)
E:\anaconda\lib\site-packages\notebook\services\contents\manager.py:351: MissingIDFieldWarning: Code cell is missing an id field, this will become a hard error in future nbformat versions. You may want to use normalize() on your notebooks before validations (available since nbformat 5.1.4). Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
validate_nb(model['content'])

请问这应该怎么解决?

我检查了端口是否占用,显示没有,更新了jupyter,仍然这样。

阅读 1.3k
avatarAI BotBETA

可能的解决方案

  1. 重启 Jupyter Notebook 服务

    • 关闭当前正在运行的 Jupyter Notebook 服务(通常在命令行中按 Ctrl+C 然后按 Y 确认)。
    • 重新启动 Jupyter Notebook 服务,看看问题是否仍然存在。
  2. 检查并更新 Jupyter 相关包

    • 你已经提到更新了 Jupyter,但确保所有相关的包(如 jupyterlab, jupyter_client, nbformat 等)都是最新的。可以使用以下命令来更新这些包:

      pip install --upgrade notebook jupyterlab jupyter_client nbformat
    • 或者如果你使用的是 Anaconda,可以使用:

      conda update notebook jupyterlab jupyter_client nbformat
  3. 检查内核日志

    • 查看 Jupyter 的详细日志输出,特别是与内核启动和连接相关的部分。你提供的日志中有一些警告信息(如 date_default is deprecatedcoroutine 'WebSocketHandler.get' was never awaited),这些可能指示了潜在的兼容性问题或错误。
    • 有时内核可能因为某些原因(如内存不足、依赖问题)而无法正常启动。
  4. 尝试使用不同的浏览器或清理浏览器缓存

    • 有时候,浏览器的缓存或插件可能会影响 Jupyter Notebook 的正常运行。尝试使用不同的浏览器访问 Jupyter Notebook,或清理当前浏览器的缓存和 Cookie。
  5. 检查防火墙或安全软件设置

    • 确保没有防火墙或安全软件阻止 Jupyter Notebook 的运行或访问。特别是确保 Jupyter Notebook 使用的端口(默认是 8888)没有被防火墙规则阻止。
  6. 查看 Jupyter Notebook 的配置文件

    • 检查 Jupyter Notebook 的配置文件(通常位于 ~/.jupyter/jupyter_notebook_config.py),确认没有不当的配置可能影响到内核的启动或连接。
  7. 尝试创建新的虚拟环境

    • 有时候,系统环境中的包冲突或损坏可能导致问题。尝试在一个全新的虚拟环境中安装 Jupyter Notebook 和相关依赖,然后看看问题是否仍然存在。

如果以上方法都不能解决问题,可能需要更深入地检查具体的错误日志或系统配置,或者考虑在 Jupyter 社区论坛、Stack Overflow 等平台寻求更专业的帮助。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题