I have the following error message on windows 64-bit and Python 2.7.
the liblas module version is libLAS-1.7.0.win-amd64-py2.7.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
The module is installed in
C:\Python27\Lib\site-packages\liblas
i used this module several times (it's a core module of my work), but today i have this problem. I unistalled liblas, reinstalled, unistalled all Python and all modules, and reinstall everything bit i have always the same problem.
If you have 64-bit version of Python installed and LibLAS dll 32-bit, then you can get this type of error. If so, then you can find 64-bit version of this library on this site (there are actually a lot of other 32-bit and 64-bit libraries for Python).
Related
I'm using my company's VM which already has Python 2.7 (comes with the OS) and Python 3.6.13 (Installed by the company)
Recently, there is a need to upgrade an application to latest version of Python ie: 3.10.2
So, I installed Python 3.10.2 in a local directory inside my $HOME. I referred to this link for the installation link.
While 2.7 & 3.6 are already there in the system.
Now, when I try to create a VENV with this python version (3.10.2), I see this error:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 69, in <module>
import msvcrt
ModuleNotFoundError: No module named 'msvcrt'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 146, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/venv/__init__.py", line 10, in <module>
import subprocess
File "/export/home/sdc/python_versions/python310/python/lib/python3.10/subprocess.py", line 74, in <module>
import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
I found some solutions like this one: link but I cannot figure out how it will translate in my case since my installation directory is not /usr/local/... It is $HOME/path/to/dir
Python on Linux does not have the msvcrt module at all. It's strictly Windows only. You seem to have miscompiled your Python somehow, since it also doesn't have the _posixsubprocess module (and msvcrt is used for Windows detection in subprocess.py).
May I recommend using pyenv or asdf for custom Python versions? They're less likely to miscompile Python.
I've installed SciPy using pip on Windows Powershell. I used the command py -m pip install scipy. This worked. I then tried to import scipy into Python, but I get this error
Traceback (most recent call last):
File "C:\Users\monzu\Documents\model of membrane-fiber interactions.py", line 2, in <module>
import scipy
File "C:\Users\monzu\AppData\Roaming\Python\Python39\site-packages\scipy\__init__.py", line 61, in <module>
from numpy import show_config as show_numpy_config
File "C:\Users\monzu\AppData\Roaming\Python\Python39\site-packages\numpy\__init__.py", line 138, in <module>
from . import _distributor_init
File "C:\Users\monzu\AppData\Roaming\Python\Python39\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\monzu\AppData\Local\Programs\Python\Python39-32\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
How do I fix this?
I don't know if that's the reason and how it came, but "Python39-32" and "not a valid Win32 application" may suggest a mismatch in the versions of some libraries, 32-bit vs 64-bit, or some dependency missing? Maybe a 64-bit python/numpy? is trying to import a 32-bit DLL for the cython library (the last two lines from the exception).
EDIT: I opened the __distributo_init.py file, there are these DLL loads:
#Load Intel C, Fortran, and OMP runtime DLLs into the process
import ctypes
ctypes.CDLL(os.path.join(path, 'libmmd.dll'))
ctypes.CDLL(os.path.join(path, 'libifcoremd.dll'))
ctypes.CDLL(os.path.join(path, 'libiomp5md.dll'))
ctypes.CDLL are instances of a class where it fails.
Then:
if handle is None:
self._handle = _dlopen(self._name, mode)
else:
self._handle = handle
So maybe it can't import these libraries - are they installed?
So, I keep getting this error:
OSError: [WinError 193] %1 is not a valid Win32 application
I believed it to be because of my environment variables. So, I fixed that, but still keep getting the error. I'm at a loss currently. Here's the complete error output:
Traceback (most recent call last):
File "c:\Users\angel\Desktop\Programming Related\Python\improvedTherapibot\copyImprovedBot.py", line 5, in <module>
import nltk
File "C:\Users\angel\AppData\Local\Programs\Python\Python38\lib\site-packages\nltk\__init__.py", line 128, in <module>
from nltk.collocations import *
File "C:\Users\angel\AppData\Local\Programs\Python\Python38\lib\site-packages\nltk\collocations.py", line 39, in <module>
from nltk.metrics import (
File "C:\Users\angel\AppData\Local\Programs\Python\Python38\lib\site-packages\nltk\metrics\__init__.py", line 16, in <module>
from nltk.metrics.scores import (
File "C:\Users\angel\AppData\Local\Programs\Python\Python38\lib\site-packages\nltk\metrics\scores.py", line 15, in <module>
from scipy.stats.stats import betai
File "C:\Users\angel\AppData\Roaming\Python\Python38\site-packages\scipy\__init__.py", line 106, in <module>
from . import _distributor_init
File "C:\Users\angel\AppData\Roaming\Python\Python38\site-packages\scipy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\angel\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
Edit: Here is the code I'm trying to run.
import nltk
from nltk.corpus import wordnet
good_words = []
bad_words = []
for syn in wordnet.synsets("happy"):
for l in syn.lemmas():
good_words.append(l.name())
for syn in wordnet.synsets("sad"):
for l in syn.lemmas():
bad_words.append(l.name())
print(set(good_words))
Edit 2: My os is Windows 10 and running on x64
I ran into the same OS error using, win_64 Bit and I have both python 32-bit and 64-bit installed. The problem is definitely the nltk module.
on the nltk documentation, the [nltk webpage] (https://www.nltk.org/install.html) suggests to install Windows 32-bit versions of python. Try python 32.
I would have just done a comment but I have no reputation.
OSError: [WinError 193] %1 is not a valid Win32 application
Maybe your computer's OS is not window_32, But your python version is 32-bit. So check your OS, I guess your OS is window_64, And install right python version.
Here is python installer for window_64.
python installer for win_64
Also as described in this link make sure you are using a 64 bit console e.g.
C:\Windows\SysWOW64\cmd.exe
while using pip to install your dependencies. This ensures the 64 bit version of the dependencies is installed. Also make sure you are using Python 64 bits and if loading any external .dll or .so compiled in C it was compiled using 64 bits.
I'm trying to use winpexpect on windows 7 64 bit on an AMD processor. For this, I installed pywin32, the executable called pywin32-214.win-amd64-py2.7. The graphical installer seemed to run successfully, but I get this error when I try to import winpexpect:
>>> import winpexpect
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Alexei\wordseer_flask\venv\lib\site-packages\winpexpect.py", li
ne 11, in <module>
import pywintypes
File "C:\Users\Alexei\wordseer_flask\venv\lib\site-packages\pywin32-214-py2.7-
win32.egg\pywintypes.py", line 124, in <module>
__import_pywin32_system_module__("pywintypes", globals())
File "C:\Users\Alexei\wordseer_flask\venv\lib\site-packages\pywin32-214-py2.7-
win32.egg\pywintypes.py", line 64, in __import_pywin32_system_module__
import _win32sysloader
ImportError: DLL load failed: %1 is not a valid Win32 application.
When I try to run C:\Python27\Scripts\pywin32_postinstall:
C:\Windows\system32>C:\Python27\Scripts\pywin32_postinstall.py -install
Traceback (most recent call last):
File "C:\Python27\Scripts\pywin32_postinstall.py", line 601, in <module>
install()
File "C:\Python27\Scripts\pywin32_postinstall.py", line 311, in install
LoadSystemModule(lib_dir, "pywintypes")
File "C:\Python27\Scripts\pywin32_postinstall.py", line 149, in LoadSystemModu
le
('.dll', 'rb', imp.C_EXTENSION))
ImportError: DLL load failed: %1 is not a valid Win32 application.
When I installed pyinstaller, I also got the same error:
import _win32sysloader
ImportError: DLL load failed: The specified module could not be found.
Installing Microsoft Visual C++ 2010 Redistributable Package fixed the error.
I am installing the fdb package on windows
This package
https://pypi.python.org/pypi/fdb
and i get this error
C:\fdb>python setup.py install
Traceback (most recent call last):
File "setup.py", line 7, in <module>
from fdb import __version__
File "C:\fdb\fdb\__init__.py", line 23, in <module>
from fdb.fbcore import *
File "C:\fdb\fdb\fbcore.py", line 26, in <module>
from . import ibase
File "C:\fdb\fdb\ibase.py", line 43, in <module>
fb_library = WinDLL(fb_library_name)
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: expected string or Unicode object, NoneType found
Has anyone encountered this error before?.I have the python driver for firebird installed and also the python driver.
I solved it. After installing the Firebird super server, copy fbclient.dll (you will find it under C:\Program Files\Firebird\Firebird_2_5\bin) and paste it under C:\WINDOWS
If your problem persists, there is a hack I found on the firebird-python mailing list on Yahoo here: Re: Again: can't install fdb