OSError:[WinError 193]%1不是有效的Win32应用程序-尝试导入numpy时 [英] OSError: [WinError 193] %1 is not a valid Win32 application - when trying to import numpy

查看:1561
本文介绍了OSError:[WinError 193]%1不是有效的Win32应用程序-尝试导入numpy时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以安装numpy或pandas,但不能将它们导入cmd,jupyter笔记本或Sublime文本中. (不过,我可以在Pycharm中安装和导入它们.)

I can install numpy or pandas, but I can't import them in cmd, jupyter notebook or sublime text. (However, I can install and import them in Pycharm).

我已经搜索了不同的论坛/stackoverflow,寻求答案,但是最常见的原因例如体系结构不匹配(我使用Python 32位)或路径中的空格似乎不是这里的问题. 我尝试过重新安装Python,但是并不能解决问题.

I've already searched different forums/stackoverflow, seeking for an answer, but the most common causes like architecture mismatch (I use Python 32-bit) or spaces in paths seem not to be the issue here. I've tried reinstall Python, but it didn't solve the problem.

该错误总是指出"ctypes" lib,特别是numpy模块似乎有问题.当我尝试导入pandas/matplotlib时,导入numpy失败.

The error always points out at "ctypes" lib and it seems to be a problem with numpy module specifically. When I try to import pandas/matplotlib it fails with importing numpy.

>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jadwi\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 142, in <module>
    from . import core
  File "C:\Users\jadwi\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 23, in <module>
    WinDLL(os.path.abspath(filename))
  File "C:\Users\jadwi\AppData\Local\Programs\Python\Python37-32\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

>>> help('numpy')
problem in numpy - OSError: [WinError 193] %1 is not a valid Win32 application 

>>> import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jadwi\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\__init__.py", line 13, in <module>
    __import__(dependency)
  File "C:\Users\jadwi\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 142, in <module>
    from . import core
  File "C:\Users\jadwi\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 23, in <module>
    WinDLL(os.path.abspath(filename))
  File "C:\Users\jadwi\AppData\Local\Programs\Python\Python37-32\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application

我知道人们以前曾犯过这个错误,但是,正如我提到的那样,这似乎不是体系结构不匹配的问题,路径中没有空格,我真的很固执.有关如何解决该问题的任何建议将不胜感激.

I know people had this error before, but, as I mentioned, it seems not to be an architecture mismatch problem, there are no spaces in the paths and I'm really stuck with it. Any suggestions on how to solve it will be very appreciated.

推荐答案

好的,所以这最终对我有所帮助:

Okay, so this eventually helped me:

  1. 我仅使用"pip uninstall numpy"卸载了一个numpy模块,

  1. I uninstalled only a numpy module with "pip uninstall numpy",

我再次用"pip install numpy"重新安装了它,

I reinstalled it once again with "pip install numpy",

我运行了python,仅从numpy导入了一个函数(因为我认为也许只有一部分函数无法导入,而不是整个 numpy)-来自numpy导入数组"

I ran python, imported just one function from numpy (as I thought that maybe just some of the functions can't be imported, not entire numpy) - "from numpy import array"

该函数正常工作,因此我尝试再次导入整个numpy,但是这次成功了,没有OSError.

The function worked,so I tried to import the entire numpy once again and this time it succeeded without OSError.

这篇关于OSError:[WinError 193]%1不是有效的Win32应用程序-尝试导入numpy时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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