vscode中使用 jupyter notebook:Failed to start the Kernel
先说结论:pyzmq版本过新,需要重新安装正确版本
pip uninstall pyzmq # 卸载pyzmq
pip install pyzmq==19.0.2 #安装pyzmq19.0.2版本
具体报错内容如下:
Failed to start the Kernel.
D:\Download\Python38\lib\site-packages\traitlets\traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
warn(
D:\Download\Python38\lib\site-packages\traitlets\traitlets.py:2157: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '2a720a4f-d9bd-4d7e-b0cf-bbc29778acd8' instead of 'b"2a720a4f-d9bd-4d7e-b0cf-bbc29778acd8"'.
warn(
Bad file descriptor (C:\projects\libzmq\src\epoll.cpp:100).
View Jupyter [log](command:jupyter.viewOutput) for further details.
发现我安装了两个python.exe:
尝试用另外一个,使用:
提示:
点击安装,出现报错:
Failed to start the Kernel.
内核 'base (Python 3.8.8)' 会话启动失败。
查看 Jupyter [日志](command:jupyter.viewOutput)了解更多细节。 Command failed: D:/Download/Anaconda/Scripts/activate && conda activate base && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python c:/Users/***/.vscode/extensions/ms-python.python-2022.2.1924087327/pythonFiles/printEnvVariables.py
ϵͳ�Ҳ���ָ����·����
ϵͳ�Ҳ���ָ����·����
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- cmd.exe
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
按照报错提示,执行conda init
,
重启后得到了和上一个终端一样的报错
看来必须解决这个包过期的问题。
再运行一次,这次报的错是:NameError:name'null' is not defined
上面这个还没解决,参照网上说法可以写个
global null
null = None
当然这步还无法解决问题。
回到包的问题:
参考 https://blog.csdn.net/Mammalss/article/details/123238726 ,这里诊断认为是pyzmq的版本太新(pyzmq22.3.0版本会使得ipython不能正常工作,致使jupyter无法正常工作)
ls
查看pyzmq版本,发现正是22.3.0
我们只需
pip uninstall pyzmq # 卸载pyzmq
pip install pyzmq==19.0.2 #安装pyzmq19.0.2版本
发现重装完pyzmq就可以正常使用jupyter了
来源:西格码