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?
Related
I am trying to import 2 libraries into python, and there seems to be always an issue.
I have even tried to import other libraries to see if the issue is with the specific libraries I want to use, but I still get the same issue. I need to use Pandas and Matplotlib if that helps.
I always enter:
import pandas as pd
import matplotlib as plt
For matplotlib, i get this error:
PS C:\Users\mghaf\Documents\GitHub\Modelling-Cell-Growth-in-CFU> & C:/Users/mghaf/Anaconda3/python.exe c:/Users/mghaf/Desktop/ter/Covid-File-For-CC.py
Traceback (most recent call last):
File "c:/Users/mghaf/Desktop/ter/Covid-File-For-CC.py", line 1, in <module>
import matplotlib
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\matplotlib\__init__.py", line 107, in <module>
from . import cbook, rcsetup
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\matplotlib\cbook\__init__.py", line 28, in <module>
import numpy as np
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\numpy\__init__.py", line 148, in <module>
from . import _distributor_init
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\mghaf\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
For pandas I get this error:
PS C:\Users\mghaf\Documents\GitHub\Modelling-Cell-Growth-in-CFU> & C:/Users/mghaf/Anaconda3/python.exe c:/Users/mghaf/Desktop/ter/Covid-File-For-CC.py
Traceback (most recent call last):
File "c:/Users/mghaf/Desktop/ter/Covid-File-For-CC.py", line 1, in <module>
import pandas
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\pandas\__init__.py", line 11, in <module>
__import__(dependency)
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\numpy\__init__.py", line 148, in <module>
from . import _distributor_init
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\numpy\_distributor_init.py", line 26, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\mghaf\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
I am using VS code to write my code. I am using Anaconda as the base for my libraries. However, I have also used pip install and uninstall multiple times to see if the issue was from there. To no avail, it did not work. There might be some issue with the setting up of python as I have both Anaconda and Python V 3.7.x installed.
If there is anything that I need to do in my settings or anything else then I would appreciate it someone could inform me on how to do it. Thanks in Advance!
This is an issue caused due to multiple python path. To elaborate, your expected interpreter is C:/Users/mghaf/Anaconda3/python.exe as seen from your executing command.
PS C:\Us ... in-CFU> & C:/Users/mghaf/Anaconda3/python.exe c:/Us ... CC.py
Although, from the error logs, it is visible that it is using an alternate python from C:\Users\mghaf\AppData\Roaming\Python\Python38 as seen here
File "C:\Users\mghaf\AppData\Roaming\Python\Python38\site-packages\pandas\__init__.py", line 11, in <module>
I would suggest that you remove all python paths from your Windows machine apart from anything related to your Anaconda interpreter.
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 am trying to import Keras (using tensorflow), and I am getting this error. I have tried everything I found in the Internet, but still does not work. Please I will appreciate a lot if you help me.
I have read is something with the 32bits and 64bits versions. I have tried everything (downloaded and uninstalled several times everything).
I am pretty sure the problem is with the numpy DLL.
Traceback (most recent call last):
File "versiones.py", line 2, in <module>
import scipy
File "C:\Users\Public\ANACONDA\lib\site-packages\scipy\__init__.py", line 62, in <module>
from numpy import show_config as show_numpy_config
File "C:\Users\Marcos Rusinol\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\Users\Marcos Rusinol\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 23, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Users\Public\ANACONDA\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 no es una aplicación Win32 válida
I solved the problem!
I just download a 64 NUMPY wheel and installed it.
So I'm trying to import jit from the numba library but the import produces an OSError and says that a specific module couldn't be found.
I tried to uninstall and reinstall numba, but it didn't change anything and I have no other idea to solve the issue.
Here is the full error:
Traceback (most recent call last):
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\llvmlite\binding\ffi.py", line 42, in <module>
lib = ctypes.CDLL(os.path.join(_lib_dir, _lib_name))
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\ctypes\__init__.py", line 350, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] Le module spécifié est introuvable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:/Users/user65/HypotheseDecoupageReseau/CalculInfluence.py", line 6, in <module>
from numba import jit
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\numba\__init__.py", line 11, in <module>
from . import config, errors, runtests, types
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\numba\config.py", line 11, in <module>
import llvmlite.binding as ll
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\llvmlite\binding\__init__.py", line 6, in <module>
from .dylib import *
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\llvmlite\binding\dylib.py", line 4, in <module>
from . import ffi
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\site-packages\llvmlite\binding\ffi.py", line 47, in <module>
lib = ctypes.CDLL(_lib_name)
File "D:\Users\user65\Logiciels\WinPython-64bit-3.4.4.6Qt5\python-3.4.4.amd64\lib\ctypes\__init__.py", line 350, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] Le module spécifié est introuvable
Process finished with exit code 1
Thank you for your help :)
As said in this page you are not alone. This is the problem of the version 3.4.4
You have some options:
Try upgrading and see that the problem solves.
Aside from that people saying It's due to script\python.bat and python.exe interfering.
python.bat is currently calling ptpython when it sees it, which has not the same syntax.
You may try pip uninstall ptpython and see if it helps.
You may also copy the current python.bat as winpython.bat, and keep python.bat calling only python:
#echo off
call "%~dp0env_for_icons.bat"
cd/D "%WINPYWORKDIR%"
rem backward compatibility for python.exe
"%WINPYDIR%\python.exe" %*
After following the above solutions, llvmlite error part should be solved by now. You should have Visual Studio 2015 installed for other error parts to go away.
Although you can instead install vc_redist.x86.exe alone from this link and dont install the whole VS2015. Follow here for more information.
Check if you are using a compatible version of Python.
In my case I had to remove Python and downgrade to a previous version
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).