Warm tip: This article is reproduced from serverfault.com, please click

Error importing numpy, pandas, etc: OSError: [WinError 193] %1 is not a valid Win32 application

发布于 2020-01-17 02:55:57

I am complete python noob - and I've been following some tutorials until I reached a problem that seems to be above my current knowledge.

I'm using 64bit Anaconda. When I try to import a library, like:

import numpy

I get the following error:

OSError: [WinError 193] %1 is not a valid Win32 application

Alongside the following traceback:

runfile('C:/Users/default.LAPTOP-UGHKEJ3G/Desktop/untitled0.py', wdir='C:/Users/default.LAPTOP-UGHKEJ3G/Desktop')
Traceback (most recent call last):

  File "<ipython-input-29-3ecc1d2f2c89>", line 1, in <module>
    runfile('C:/Users/default.LAPTOP-UGHKEJ3G/Desktop/untitled0.py', wdir='C:/Users/default.LAPTOP-UGHKEJ3G/Desktop')

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/default.LAPTOP-UGHKEJ3G/Desktop/untitled0.py", line 8, in <module>
    import numpy

  File "C:\Users\default.LAPTOP-UGHKEJ3G\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 142, in <module>
    from . import core

  File "C:\Users\default.LAPTOP-UGHKEJ3G\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 23, in <module>
    WinDLL(os.path.abspath(filename))

  File "C:\ProgramData\Anaconda3\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)

I'm not really sure what to do. I've checked all the other threads on it, uninstalled any python versions, uninstalled and re-installed Anaconda, uninstalled and re-installed numpy. I'm all out of ideas!

Any suggestions would be welcome!

Questioner
Ageras
Viewed
11
Lalo Ramírez 2020-01-17 11:17:30

You have installed a 64 bit version of numpy and are using a 32 bit version of python or vice versa. You can install a prebuilt binary from here