Python错误:OSError:[WinError 193]%1不是有效的Win32应用程序 [英] Python error: OSError: [WinError 193] %1 is not a valid Win32 application

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

问题描述

使用Anaconda Navigator更新一些软件包(numpy,matplotlib等)和Spyder之后;我使用这些软件包的代码不再起作用,并且在导入时出现错误.

After using Anaconda Navigator to update some packages (numpy, matplotlib, ...) and Spyder; my code using these packages no longer works and gives error on import.

  • 我试图将更新撤消到以前的版本安装,没有成功.

  • I tried to reverse the update to a previous version installation, without success.

我检查了 Python产生:OSError:[WinError 193]%1不是有效的Win32应用程序;但没有解决办法.

I checked Python produces: OSError: [WinError 193] %1 is not a valid Win32 application; but no solution.

我检查了 https://github.com/pytorch/pytorch/issues/27693 ,然后看了看在Windows上的PATH中使用对用户和用户的环境变量系统;但我不知道要寻找什么.oggyoggy448建议删除并重新安装numpy;尝试了几次,然后重新启动我的电脑但没有成功.

I checked https://github.com/pytorch/pytorch/issues/27693 and looked in the PATH on Windows using Environment Variables for User and System; but I don't know what to look for. oggyoggy448 suggested to remove and reinstall numpy; tried it a few times and restarting my PC but no success.

https://python-forum.io/Thread-WinError-193-1-is-not-a-valid-Win32-application 建议从命令行运行;您可以在下面找到.

https://python-forum.io/Thread-WinError-193-1-is-not-a-valid-Win32-application suggested running from the command line; which you can find below.

https://superuser.com/questions/1485333/getting-oserror-winerror-193-1-is-not-a-valid-win32-application-while-trying 显示了类似的错误.

我尝试完全卸载Anaconda,并且所有python版本均已卸载我的电脑;重新安装Anaconda和Spyder之后;一样的问题仍然存在.

I tried uninstalling Anaconda completely and all python versions on my PC; after reinstalling Anaconda and Spyder; the same problem remains.

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

Looking forward to a better understanding and the resolving suggestion ...

使用IPython控制台并在下面输入内容时

While using the IPython console and just typing below:

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

推荐答案

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

After a couple of nights, the following worked for me (hopefully it may be useful to others having the same problem):

在Ipython环境中,键入:

In an Ipython environment, typing:

In [1]: import numpy

给出上述错误.所以我做了以下事情:

gave the error as shown above. So I did the following:

In [2]: pip uninstall numpy

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

getting some lines of code and confirming that numpy is being removed. After that I tried:

In [3]: import numpy

没有错误,一切似乎都正常!(之间没有进行任何安装!)就像以前在升级某些软件包期间一样,正在安装双版本的numpy并导致错误日志,如上所示.

No errors and everything seems to work! (Did not do any install in between!) As if during upgrading some packages before, a double version of numpy was being installed and causing the error log as shown above.

完全相同的过程也适用于Matplotlib(卸载而不是重新安装)使其起作用.希望这会有所帮助.

Exactly the same procedure worked for Matplotlib as well (uninstall and not reinstalling) made it work. Hope this is helpful.

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

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