VSCode中Jupyter内核因pyzmq模块启动失败求助
解决Jupyter内核启动时pyzmq模块错误的方案
1. 确认Python环境一致性
- 检查VSCode左下角显示的当前Python解释器路径,和终端中执行
which python(Linux/macOS)或where python(Windows)输出的路径是否一致 - 若不一致,按下
Ctrl+Shift+P(Windows/Linux)或Cmd+Shift+P(macOS),输入Python: Select Interpreter切换到对应环境
2. 彻底重装pyzmq及相关依赖
- 完全卸载pyzmq:
pip uninstall -y pyzmq - 清理pip缓存:
pip cache purge - 安装兼容性稳定的pyzmq版本:
pip install pyzmq==25.1.0 - 更新Jupyter相关核心依赖:
pip install --upgrade jupyter ipykernel
3. 重新注册IPython内核
- 在目标环境中执行命令注册内核(替换
your_env_name为你的环境名称):python -m ipykernel install --user --name=your_env_name - 重启VSCode后,在Jupyter会话中选择刚注册的内核
4. 检查VSCode Jupyter扩展状态
- 打开VSCode扩展面板,确保Jupyter扩展为最新版本,若不是则点击更新
- 尝试禁用并重新启用Jupyter扩展,再重启VSCode
5. 虚拟环境问题排查(若使用虚拟环境)
- 若用conda环境,尝试通过conda安装pyzmq:
conda install -c conda-forge pyzmq - 若环境损坏,可重建环境后重新安装依赖:
conda remove -n your_env_name --all conda create -n your_env_name python=3.9 conda activate your_env_name pip install gym_super_mario_bros jupyter pyzmq
错误提示原文:
The kernel failed to start due to an error with the 'pyzmq' module. Consider re-installing this module.
内容的提问来源于stack exchange,提问作者Timothy Bennett
相关产品推荐
相关产品推荐

