DLL 文件 OSError: [WinError 1401] 应用程序无法启动问题解决
因为应用程序的并行配置不正确
import ctypes
dll = ctypes.windll.LoadLibrary(r"D:\1-python\dist\dll\ControlCAN.dll")
print("DLL 加载成功!")
项目 | 状态 |
---|---|
DLL 路径 | ✅ 正确 |
DLL 文件 | ✅ 存在 |
Python 位数 | ✅ 64位(与 DLL 匹配64位) |
错误原因 | ❌ 缺少 Visual C++ 运行库(VC++ Redistributable) |
只需要安装 Visual C++ 2008 SP1 Redistributable Package (x64),而不是整个 Visual Studio。
https://aka.ms/vs/17/release/vc_redist.x64.exe
Microsoft Visual C++ 2008 SP1 Redistributable Package (x64):
https://download.microsoft.com/download/5/D/8/5D8C65CB-C849-4025-8E95-C3966CAFD8AE/vcredist_x64.exe
✅ 安装步骤
下载 vcredist_x64.exe;
双击运行 → 按提示完成安装;
重启电脑;(必须重启,否则注册表/WinSxS 不会刷新。)
再次运行 Python 程序,确认 DLL 能正常加载。