WindowsError: [Error 193] %1 is not a valid Win32 application in Python
Asked Answered
M

4

4

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:\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.

Michellmichella answered 13/3, 2013 at 0:13 Comment(1)
fist i have always a problem windowsError. Second, it's not a problem of liblas but a Pyscript problem. I can imprt liblas in IDLE of Python without problem (as i wrote). But thanks for the tryMichellmichella
C
3

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:\Python27\lib\site-packages\liblas , find the extension dll and see its type via dumpbin , here is some picture for demonstration :

enter image description here

Correna answered 13/3, 2013 at 0:41 Comment(7)
i am super sure to have Python 2.7.3 64 bit. If i install PyScripter-v2.5.3-Setup.exe i cannot run PythonMichellmichella
@Gianni , please take a look at #5539171 , I think libals backend dll is a 32b one, so maybe using Python 32b will mitigate the issueCorrena
I suppose in Win64, a 64-bit process must be all 64-bitMichellmichella
i can run liblas in Python IDLE without problem. I have liblas on other 64bit PC and i can run with pyscript without problem. I had run for months liblas without problemsMichellmichella
This is exactly my point, maybe the libals dll is a 32b module after all (you can verify it via the usage of dumpbin or dependency walker)Correna
could you explain i can verify it via the usage of dumpbin? thanksMichellmichella
@Gianni I've updated my answer w/ more information (sorry for my late response)Correna
A
2

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.

You can see the version you are running in the Python terminal window (highlighted in bold)

Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32

Download here

https://www.microsoft.com/en-us/download/details.aspx?id=48145

Arbitrate answered 24/3, 2016 at 14:1 Comment(0)
A
1

You are probably using 64 bits Python. You should install the 32 bits version instead.

Appertain answered 6/9, 2018 at 17:17 Comment(1)
is not that. ive tried 64 and 32 and both didnt workDeweydewhirst
E
0

If you got this error too, plase take a look at your python.exe file.

In my case it was corrupted as you can see below:

enter image description here

So I copied from another venv and reinstalled the dependencies.

Then it worked :)

En answered 26/2, 2021 at 14:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.