简体   繁体   English

在 VS Code 中更改 Jupyter Kernel 失败

[英]Failed to change the Jupyter Kernel in VS Code

I want to work on my Jupyter Notebook side the VS Code for the first time.我想第一次在我的 Jupyter Notebook 端使用 VS Code。 When I load the file and run the first cell, I saw this message:当我加载文件并运行第一个单元格时,我看到了这条消息: 在此处输入图像描述

Considering I have Anaconda on my system and this file works there without any problem, I tried to switch the Jupyter kernel via clicking on the top right corner option:考虑到我的系统上有 Anaconda 并且该文件在那里没有任何问题,我尝试通过单击右上角的选项来切换 Jupyter kernel:

在此处输入图像描述

It shows me a popup in the left corner:它在左角向我显示了一个弹出窗口:

在此处输入图像描述

Consider that I already switched the interpreter into my active conda env, here the name is: ERML:考虑到我已经将解释器切换到我的活动 conda env 中,这里的名称是:ERML:

在此处输入图像描述

after confirming the installation, the terminal output is like this:确认安装后,终端output是这样的:

(ERML) C:\uni_siegen\ERML>C:/Users/HPTav/anaconda3/python.exe c:\Users\HPTav\.vscode\extensions\ms-python.python-2021.5.842923320\pythonFiles\pyvsc-run-isolated.py c:\Users\HPTav\.vscode\extensions\ms-python.python-2021.5.842923320\pythonFiles\shell_exec.py C:/Users/HPTav/anaconda3/Scripts/conda.exe install --name base ipykernel -y C:/Users/HPTav/AppData/Local/Temp/tmp-189602TyUrjDemNEd.log
Executing command in shell >> C:/Users/HPTav/anaconda3/Scripts/conda.exe install --name base ipykernel -y
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
(ERML) C:\uni_siegen\ERML>

But still, the kernel is the same and it doesn't change, also the code cannot be run at all.但是,kernel 还是一样的,没有变化,代码也根本无法运行。

It's not the problem about the VSCode while the pyzmq package installed in the conda(base) environment, and you can find the jupyter notebook work well in the virtual environment of conda. pyzmq package 安装在 conda conda(base)环境中时,VSCode 没有问题,您可以发现 jupyter notebook 在 conda 的虚拟环境中运行良好。

When you run the jupyter notebook directly in the terminal under the conda(base) environment, you will find the problem of it:当你在conda(base)环境下直接在终端运行jupyter notebook时,你会发现它的问题: 在此处输入图像描述

And after you uninstall and install the pyzmq package, the jupyter notebook under conda(base) environment work well:卸载并安装 pyzmq package 后,conda(base) 环境下的 jupyter notebook 运行良好: 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM