WindowsError: [错误 193] %1 不是 Python 中的有效 Win32 应用程序 [英] WindowsError: [Error 193] %1 is not a valid Win32 application in Python

查看:155
本文介绍了WindowsError: [错误 193] %1 不是 Python 中的有效 Win32 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在 64 位窗口的 Python 2.7 中导入 liblas 模块.如果我使用 IDLE (Python GUI) 导入模块,我没有问题.

如果我使用 PyScripter "PyScripter-v2.5.3-x64-Setup.exe" 我收到此错误消息.

<预><代码>>>>导入库回溯(最近一次调用最后一次):文件<交互式输入>",第 1 行,在 <module> 中文件C:Python27libsite-packagesliblas\__init__.py",第 2 行,在 <module>从核心导入 get_version文件C:Python27libsite-packagesliblascore.py",第 138 行,在 <module> 中las = ctypes.CDLL(os.path.join(local_dlls, lib_name))文件C:Python27Libctypes\__init__.py",第 365 行,在 __init__ 中self._handle = _dlopen(self._name, mode)WindowsError: [错误 193] %1 不是有效的 Win32 应用程序

我在 PyScripter 中多次使用 liblas 没有问题,现在我可以加载所有标准模块(例如:numpy、GDAL 等),但是今晚(我需要完成分析!!!)我有这个不便.

解决方案

请确保使用 Python 2.7 64b 版 :) 或者即使您使用的是 64b 操作系统,也请使用 PyScripter 的 x86 (AKA 32b) 版

编辑 1(在与 Gianni 交换意见之后)

一个人应该验证他/她的整个 Python 进程由 32b/64b 构建意义上的相同实体组成"(例如,如果您的 Python 解释器是 32b 一个,那么它必须使用 C 类型来来自被编译为 32b dll 的 C dll Python 扩展).

在我们的示例 (liblas) 中,应该转到 C:Python27libsite-packagesliblas ,找到扩展 dll 并通过 dumpbin ,这是一些演示图片:

I wish to import liblas module in Python 2.7 on window 64bit. If I import the module with IDLE (Python GUI) I have no problem.

If I use PyScripter "PyScripter-v2.5.3-x64-Setup.exe" I get this error message.

>>> import liblas
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:Python27libsite-packagesliblas\__init__.py", line 2, in <module>
    from core import get_version
  File "C:Python27libsite-packagesliblascore.py", line 138, in <module>
    las = ctypes.CDLL(os.path.join(local_dlls, lib_name))
  File "C:Python27Libctypes\__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.

解决方案

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

Edit 1 (following comments exchange w/ Gianni)

One should verify his/her entire Python 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).

In our example (liblas) one should go to C:Python27libsite-packagesliblas , find the extension dll and see its type via dumpbin , here is some picture for demonstration :

这篇关于WindowsError: [错误 193] %1 不是 Python 中的有效 Win32 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆