[英]python failed to load 64 bit DLL on a 64 bit Windows
I wa testing a small python program that called underlying DLL libs. 我正在测试一个称为基础DLL库的小型python程序。
My system is 64bit windows 7. The python executable is the one shipped with 64 bit Anaconda3, kicked off inside Anaconda's virtual environment. 我的系统是64位Windows7。python可执行文件是随Anaconda虚拟环境启动的64位Anaconda3附带的文件。
First thing came to my attention is that this python code 首先引起我注意的是这段python代码
sys.platform
return win32 even for a AMD64 Arch, "platform.machine()" seemed returning a more accurate result. 即使对于AMD64 Arch也返回win32,“ platform.machine()”似乎返回了更准确的结果。
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] on win32
I did find some SO posts discussing this issue, such as this one . 我确实找到了一些讨论该问题的SO帖子,例如this 。
and then the program failed when trying to load a DLL file: 然后在尝试加载DLL文件时程序失败:
windll.LoadLibrary(realpath(join(_module_location, 'dlh', 'win64', 'I_cant_tell_you_the_name.dll')))
Error message: 错误信息:
OSError: [WinError 193] %1 is not a valid Win32 application
Question is, why python can't load a 64 bit DLL in a 64 bit environment? 问题是,为什么python无法在64位环境中加载64位DLL? it seemed to me the compiler insisted on loading a 32 bit DLL instead.
在我看来,编译器坚持改为加载32位DLL。 Why is that?
这是为什么? Or that the venv that Anaconda created support only 32 bit code?
还是Anaconda创建的venv仅支持32位代码?
Unfortunately I didn't have a 32 bit DLL for testing, otherwise I'd like to see how that went. 不幸的是,我没有用于测试的32位DLL,否则我想看看效果如何。
You can use Dependency Walker to check what's happening. 您可以使用Dependency Walker来检查正在发生的事情。 It has a profiling feature that will trace all library loads.
它具有可跟踪所有库加载的配置文件功能。
A few possible issues it can show you: 它可能会向您显示一些可能的问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.