WindowsError: [错误 193] %1 不是 Python 中的有效 Win32 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15374710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WindowsError: [Error 193] %1 is not a valid Win32 application in Python
提问by Gianni Spear
I wish to import liblasmodule in Python 2.7 on window 64bit. If I import the module with IDLE (Python GUI) I have no problem.
我希望在 64 位窗口上的 Python 2.7 中导入liblas模块。如果我使用 IDLE (Python GUI) 导入模块,我没有问题。
If I use PyScripter"PyScripter-v2.5.3-x64-Setup.exe" I get this error message.
如果我使用PyScripter“PyScripter-v2.5.3-x64-Setup.exe”,我会收到此错误消息。
>>> import liblas
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\lib\site-packages\liblas\__init__.py", line 2, in <module>
from core import get_version
File "C:\Python27\lib\site-packages\liblas\core.py", line 138, in <module>
las = ctypes.CDLL(os.path.join(local_dlls, lib_name))
File "C:\Python27\Lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application
I have used liblas in PyScripter many times without problem and right now I can load all standard modules (e.g.: numpy, GDAL, etc.), but tonight (I need to finish an analysis!!!) I have this inconvenience.
我在 PyScripter 中多次使用 liblas 没有问题,现在我可以加载所有标准模块(例如:numpy、GDAL 等),但今晚(我需要完成分析!!!)我有这个不便。
回答by Shmil The Cat
Please make sure to have Python 2.7 64b edition :) or even though you are working on 64b OS, use the x86 (AKA 32b) edition of PyScripter
请确保拥有 Python 2.7 64b 版 :) 或者即使您在 64b 操作系统上工作,也请使用 PyScripter 的 x86(AKA 32b)版
Edit 1 (following comments exchange w/ Gianni)
编辑 1(以下评论与 Gianni 交流)
One should verify his/her entirePython process "composed" from same entities in the sense of 32b/64b builds (e.g. if your Python interpreter is 32b one, then it must use C types coming from C dll Python extensions which were compiled as 32b dlls).
一个人应该验证他/她的整个Python 进程是由 32b/64b 构建意义上的相同实体“组成”的(例如,如果你的 Python 解释器是 32b 之一,那么它必须使用来自 C dll Python 扩展的 C 类型,这些 C 类型被编译为 32b dll)。
In our example (liblas) one should go to C:\Python27\lib\site-packages\liblas, find the extension dll and see its type via dumpbin, here is some picture for demonstration :
在我们的示例(liblas)中,应该去C:\Python27\lib\site-packages\liblas,找到扩展 dll 并通过dumpbin查看其类型,这是一些演示图片:


回答by Iain Hunter
This error can also be caused because the DLL that Python is attempting to run has been compiled on a newer version of C++. Make sure you are running the latest version of the Microsoft C++ Distribution.
这个错误也可能是因为 Python 试图运行的 DLL 是在较新版本的 C++ 上编译的。确保您运行的是最新版本的 Microsoft C++ 分发版。
You can see the version you are running in the Python terminal window (highlighted in bold)
您可以在 Python 终端窗口中看到您正在运行的版本(以粗体突出显示)
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
Python 3.5.1(v3.5.1:37a07cee5969,2015 年 12 月 6 日,01:38:48)[ MSC v.1900 32 位(英特尔)] 在 win32 上
Download here
在这里下载
https://www.microsoft.com/en-us/download/details.aspx?id=48145
https://www.microsoft.com/en-us/download/details.aspx?id=48145
回答by Tom
You are probably using 64 bits Python. You should install the 32 bitsversion instead.
您可能正在使用 64 位 Python。您应该安装32 位版本。

