在 32 位 python 解释器中导入 64 位 dll 时的 ImportError
The ImportError when importing 64bit dlls within 32bit python interpreter
在 64 位 python
解释器中导入 32 位代码的错误代码是
ImportError: DLL load failed: %1 is not a valid Win32 application.
这是否与在 32 位 python
解释器中导入 64 位代码时引发的错误相同?
如果不是,那是什么错误?
更新: 我误读了原来的问题(基于它使用术语 "application" 而它的意思是 "extension module")。当您谈论将不兼容的扩展模块加载到 Python 时,错误结果应该是相同的; 32 位 DLL(扩展模块只是 Windows 上 DLL 的一个小特例)与 64 位 Python 可执行文件不兼容,而 64 位 DLL 与 32 位 Python 不兼容] 可执行文件,出于相同的基本原因,错误消息(派生自尝试动态加载具有不兼容位的 DLL 时返回的 Windows 错误代码)将是相同的。
关于为后代保留的应用程序与模块的原始答案,但与 OP 无关:
肯定不是同一个错误;启动 64 位程序根本不是导入模块,因此它不会引发 ImportError
.
就此而言,只要 OS 是 64 位并且支持 运行 32 位和 64 位进程的混合,32 位 Python 应该不会遇到问题启动 64 位程序;问题是在同一过程中混合和匹配 32 位和 64 位代码;两个不相关的进程可以具有 OS/hardware 支持的任何位数。
以问答形式...在 64 位 Windows 机器上
- 直接从
python.org
下载 python
32bit
- 已从
gohlke/pythonlibs/
和 .pyd
文件 下载 32bit
和 64bit
的 pyFFTW
dll
运行 均导入...
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyfftw32
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
>>> import pyfftw64
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.
因此在 a 中加载 64bit
应用程序也会得到相同的 ImportError
我还用其他 64 位 .pyd
二进制文件检查了这个,它给出了类似的错误。
在 64 位 python
解释器中导入 32 位代码的错误代码是
ImportError: DLL load failed: %1 is not a valid Win32 application.
这是否与在 32 位 python
解释器中导入 64 位代码时引发的错误相同?
如果不是,那是什么错误?
更新: 我误读了原来的问题(基于它使用术语 "application" 而它的意思是 "extension module")。当您谈论将不兼容的扩展模块加载到 Python 时,错误结果应该是相同的; 32 位 DLL(扩展模块只是 Windows 上 DLL 的一个小特例)与 64 位 Python 可执行文件不兼容,而 64 位 DLL 与 32 位 Python 不兼容] 可执行文件,出于相同的基本原因,错误消息(派生自尝试动态加载具有不兼容位的 DLL 时返回的 Windows 错误代码)将是相同的。
关于为后代保留的应用程序与模块的原始答案,但与 OP 无关:
肯定不是同一个错误;启动 64 位程序根本不是导入模块,因此它不会引发 ImportError
.
就此而言,只要 OS 是 64 位并且支持 运行 32 位和 64 位进程的混合,32 位 Python 应该不会遇到问题启动 64 位程序;问题是在同一过程中混合和匹配 32 位和 64 位代码;两个不相关的进程可以具有 OS/hardware 支持的任何位数。
以问答形式...在 64 位 Windows 机器上
- 直接从
python.org
下载python
32bit
- 已从
gohlke/pythonlibs/
和.pyd
文件 下载
32bit
和 64bit
的 pyFFTW
dll
运行 均导入...
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyfftw32
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
>>> import pyfftw64
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.
因此在 a 中加载 64bit
应用程序也会得到相同的 ImportError
我还用其他 64 位 .pyd
二进制文件检查了这个,它给出了类似的错误。