首页 > 解决方案 > 无法导入 ctypes - 架构不匹配?

问题描述

我在 64 位版本的 Windows 10 上使用 64 位版本的 python 来运行一些代码。但是,代码在导入 ctypes 时失败。实际上,该问题的最小示例很简单:

import ctypes

这里失败了:

from _ctypes import Union, Structure, Array

出现此错误:

DLL load failed: %1 is not a valid Win32 application

仔细阅读,这似乎是将 32 位 dll 加载到 64 位版本的 python 中的问题(反之亦然,但我的 python 版本是 64 位,所以......)。但是,我不明白的是,ctypes似乎是与python捆绑在一起的东西,即它是在我安装python时安装的。ctypes 本身的架构是否错误?如果它带有 64 位版本的 Python,那怎么可能呢?

标签: pythonwindowsctypes32bit-64bit

解决方案


推荐阅读