You need to enable JavaScript to run this app. Jupyter Notebook内核无法启动 提示无效数据/已终止 伴win32api DLL加载失败
优惠活动
大模型
产品
解决方案
定价
更多

Jupyter Notebook内核无法启动 提示无效数据/已终止 伴win32api DLL加载失败

Windows环境Jupyter Notebook内核启动失败(Invalid data/Dead kernel)故障处理

故障现象

  • 启动Jupyter Notebook后,新建或打开.ipynb笔记本时无法拉起内核
  • 界面弹出 Invalid data 或 Dead kernel 的错误提示

完整错误回溯

Traceback (most recent call last):
File "C:\Users\ising\AppData\Roaming\Python\Python38\site-packages\tornado\web.py", line 1703, in _execute
result = await result
File "C:\Users\ising\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info)  # type: ignore
File "C:\Users\ising\anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
model = yield maybe_future(
File "C:\Users\ising\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\ising\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info)  # type: ignore
File "C:\Users\ising\anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\ising\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\ising\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info)  # type: ignore
File "C:\Users\ising\anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 100, in start_kernel_for_session
kernel_id = yield maybe_future(
File "C:\Users\ising\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\ising\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\ising\anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\ising\anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 186, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\ising\anaconda3\lib\site-packages\jupyter_client\manager.py", line 304, in start_kernel
kernel_cmd, kw = self.pre_start_kernel(**kw)
File "C:\Users\ising\anaconda3\lib\site-packages\jupyter_client\manager.py", line 251, in pre_start_kernel
self.write_connection_file()
File "C:\Users\ising\anaconda3\lib\site-packages\jupyter_client\connect.py", line 468, in write_connection_file
self.connection_file, cfg = write_connection_file(self.connection_file,
File "C:\Users\ising\anaconda3\lib\site-packages\jupyter_client\connect.py", line 138, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\ising\anaconda3\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\ising\anaconda3\lib\site-packages\jupyter_core\paths.py", line 435, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\ising\anaconda3\lib\site-packages\jupyter_core\paths.py", line 361, in win32_restrict_file_to_user
import win32api
ImportError: 导入win32api时DLL加载失败:%1 不是有效的Win32应用程序。

故障根因

  • 错误链路最终终止于win32api导入环节,抛出*%1 不是有效的Win32应用程序*提示,核心诱因是提供win32api接口的pywin32依赖存在问题:
    • 安装的pywin32包架构与当前运行Python的位数(32位/64位)不匹配
    • pywin32包文件损坏、版本与当前Python环境不兼容
  • 从回溯的文件路径可见,系统同时加载了*用户级Python38(路径:C:\Users\ising\AppData\Roaming\Python\Python38)和Anaconda内置Python(路径:C:\Users\ising\anaconda3)*的Jupyter组件,存在多环境路径交叉、依赖混乱的问题

可落地解决方案

  • 修复匹配当前Python架构的pywin32依赖
    • 先确认当前运行Jupyter的Python架构,在命令行执行:python -c "import platform; print(platform.architecture())"
    • 卸载现有损坏的pywin32包:pip uninstall pywin32 -y
    • 重新安装与当前Python位数匹配的pywin32:pip install pywin32
    • 执行pywin32初始化脚本:切换到Anaconda的Scripts目录(如C:\Users\ising\anaconda3\Scripts),运行 python pywin32_postinstall.py -install
  • 清理多Python环境的路径冲突
    • 检查系统环境变量的Path条目,移除与当前Jupyter运行环境无关的路径(比如使用Anaconda启动Jupyter时,删除用户级Python38的站点包路径)
    • 固定通过Anaconda激活环境启动Jupyter:先执行 conda activate base,再运行 jupyter notebook
  • 校验Jupyter核心组件完整性
    • 重装Anaconda内置的Jupyter核心组件:conda reinstall jupyter notebook jupyter_client jupyter_core -y

内容的提问来源于stack exchange,提问作者Avinash Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.24 11:06:02