内核出现在 jupyter notebook 中但无法正常工作

kernel appeared in jupyter notebook but not working

我打算通过以下步骤在jupyter notebook中使用虚拟环境:

conda create -n test python==3.6
conda activate test
ipython kernel install --user --name=test

然后我在 return 中得到以下内容:

Installed kernelspec test in C:\Users\User\AppData\Roaming\jupyter\kernels\test

当我看到测试内核出现在 jupyter notebook 中时,它似乎正在工作。

然而,当我切换到那个内核时,它实际上使用的是我的默认 python 环境。

我还检查了现有的内核:

λ jupyter kernelspec list
Available kernels:
  shjh       C:\Users\User\AppData\Roaming\jupyter\kernels\shjh
  test       C:\Users\User\AppData\Roaming\jupyter\kernels\test
  python3    C:\Users\User\Anaconda3\share\jupyter\kernels\python3

有但没有用...

任何解决此问题的建议。

不确定是什么导致了问题。但幸运的是我找到了一个可行的解决方案。

首先我用

删除了安装的内核
jupyter kernelspec uninstall <kernel name>

然后用ipykernel再次添加:

conda create -n test python==3.6
conda activate test
(test) λ pip install ipykernel
(test) λ python -m ipykernel install --name test --display-name "some name"