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

标签 python anaconda package

在使用 Anaconda Navigator 更新了一些包(numpy、matplotlib、...)和 Spyder 之后;我使用这些包的代码不再有效,并且在导入时出错。

期待更好的理解和解决建议...

在使用 IPython 控制台时,只需在下面输入:

In [1]: import numpy

这给出了以下输出:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-5-d4cdadb62aa7> in <module>
----> 1 import numpy

~\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py in <module>
    138
    139     # Allow distributors to run custom init code
--> 140     from . import _distributor_init
    141
    142     from . import core

~\AppData\Roaming\Python\Python37\site-packages\numpy\_distributor_init.py in <module>
     24                 # NOTE: would it change behavior to load ALL
     25                 # DLLs at this path vs. the name restriction?
---> 26                 WinDLL(os.path.abspath(filename))
     27                 DLL_filenames.append(filename)
     28     if len(DLL_filenames) > 1:

E:\Programs\Anaconda\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    362
    363         if handle is None:
--> 364             self._handle = _dlopen(self._name, mode)
    365         else:
    366             self._handle = handle

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

最佳答案

几个晚上后,以下内容对我有用(希望对遇到同样问题的其他人有用):

在 Ipython 环境中,键入:

In [1]: import numpy

报错如上。 所以我做了以下事情:

In [2]: pip uninstall numpy

获取一些代码行并确认 numpy 已被删除。之后我尝试了:

In [3]: import numpy

没有错误,一切似乎都正常! (中间没有做任何安装!) 好像之前在升级一些包时,安装了双版本的numpy,导致错误日志如上所示。

完全相同的过程也适用于 Matplotlib(卸载而不是重新安装)使其工作。

关于Python 错误 : OSError: [WinError 193] %1 is not a valid Win32 application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58512907/

相关文章:

windows - Anaconda Navigator 无法启动,download_api 错误(Windows 10)

java - 如何避免 Visual Studio Code 警告 : "[myfile].java is a non-project file, only syntax errors are reported"

r - 在 Rstudio 上安装 R 包 pcalg 时出错 : "clang: error: linker command failed with exit code 1"

android - 修改了我的项目包,但更改不影响应用程序

javascript - 尝试使用 Selenium 和 Python 通过使用框架和 Javascript 的网页登录时出现 ERR_TOO_MANY_REDIRECTS 错误

python - Django - 将模板上下文传递给表单

使用 swig 和 Anaconda Python 找不到 Python.h

python - 任何方式来判断用户的 python 环境是否是 anaconda

python - Django 设置未知参数 : TEMPLATE_DEBUG

Python Pandas : Overwriting an Index with a list of datetime objects