为什么jupyter显示“None not found”?

2024-04-27 12:37:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用jupyter来编写和编辑python代码。我打开了一个.ipynb文件,但在右上角看到“NoneNotFound”,我无法执行我编写的任何代码。奇怪的是,我会打开其他.ipynb文件,没有问题。另外,当我单击红色的“None not found”图标时,我会得到消息“None”内核不可用。请选择另一个合适的内核,或者安装该内核。我怀疑问题是jupyter没有检测到Python 3内核?它显示“Python[root]”应该是“Python 3”。有人知道如何修复这个问题吗?

Screenshot of working code

Screenshot "None not found"


Tags: 文件代码none消息编辑notjupyter内核
3条回答

更改内核Python[根] 保存、关闭并重新打开

我怀疑那个特定的.ipynb文件包含一些元数据,指定了一个尚未安装的内核-请参阅the file format specification

如果使用文本编辑器打开该文件并搜索metadata,您应该会看到如下内容:

{
  "metadata" : {
    "signature": "hex-digest", # used for authenticating unsafe outputs on load
    "kernel_info": {
        # if kernel_info is defined, its name field is required.
        "name" : "the name of the kernel"
    },
    "language_info": {
        # if language_info is defined, its name field is required.
        "name" : "the programming language of the kernel",
        "version": "the version of the language",
        "codemirror_mode": "The name of the codemirror mode to use [optional]"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0,
  "cells" : [
      # list of cell dictionaries, see below
  ],
}

其中一个选项是将内核和语言条目更改为空字典,但您可能会发现此笔记本实际上是一个iR笔记本,或其他任何笔记本。

我也有同样的问题。我的解决办法是:

  1. 在Kernel的菜单中->;更改Kernel->;选择Python[根](或 你想要的内核
  2. 保存文件
  3. 关上它
  4. 重新打开它。

相关问题 更多 >