Jupyter conda 选项卡 'An error occurred while retrieving package information.'

Jupyter conda tab 'An error occurred while retrieving package information.'

在我的根环境中 运行

$ jupyter notebook

然后在浏览器中单击 'Conda' 选项卡。这总是用来列出我的 conda 环境和其中的包。现在我收到以下错误。

我最近创建和删除了一些 conda 环境,也许这是相关的。唯一的控制台输出是

[W 10:30:20.948 NotebookApp] 404 GET /environments?_=1476811818902 (::1) 13.19ms referer=http://localhost:8888/tree
[W 10:30:20.951 NotebookApp] 404 GET /packages/available?_=1476811818903 (::1) 1.77ms referer=http://localhost:8888/tree

看到这个问题: https://github.com/Anaconda-Platform/nb_conda/issues/23

问题似乎是 conda 环境中的笔记本配置文件与用户目录中的配置文件之间存在冲突。

要解决此问题并让选项卡正确显示内容,我必须删除该文件:

rm jupyter_notebook_config.json in ~/.jupyter

请注意,对我来说,这不是问题,因为它实际上不包含任何内容。

在 windows,运行 conda install -c conda-forge nb_conda_kernels 为我工作。

正如指出的:https://github.com/Anaconda-Platform/nb_conda/issues/23#issuecomment-239813091

以下命令有助于解决问题:

jupyter serverextension disable nb_conda
jupyter serverextension enable nb_conda

这基本上重写了 ~/.jupyter 文件夹中的配置文件。

如果没有任何命令适合您,请尝试为每个环境手动添加内核(如 Andreas Mueller 所指出):

source activate <my_environment>
python -m ipykernel install --user --name <my_environment> --display-name "<Display name>"

我在这条路径中用for env in info['envs'] if env != info['root_prefix']]替换了for env in info['envs']]anaconda3\pkgs\nb_conda-2.2.1-py38_1\envmanager.py 并解决所有错误

对我来说,我只需要关闭当前的 Jupyter notebook 会话并重新启动,然后错误消失并且能够加载环境。