导入错误:DLL 加载失败:%1 不是 Python Matplotlib 的有效 Win32 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26638621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 00:47:14  来源:igfitidea点击:

ImportError: DLL load failed: %1 is not a valid Win32 application for Python Matplotlib

pythonpython-2.7matplotlibpython-2.x

提问by RAMAKRISHNA REDDY

>>> from matplotlib import pyplot as plt

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    from matplotlib import pyplot as plt
  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 24, in <module>
    import matplotlib.colorbar
  File "C:\Python27\lib\site-packages\matplotlib\colorbar.py", line 27, in <module>
    import matplotlib.artist as martist
  File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 8, in <module>
    from transforms import Bbox, IdentityTransform, TransformedBbox, \
  File "C:\Python27\lib\site-packages\matplotlib\transforms.py", line 35, in <module>
    from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: DLL load failed: %1 is not a valid Win32 application.

I am getting this error. I have tried activepython, python xy, but the error still persists.

我收到此错误。我已经尝试过activepythonpython xy但错误仍然存​​在。

回答by ThePredator

The error that you are getting is because you have installed the wrong component of matplotlib(there are the 32 bit and 64 bit components).

您得到的错误是因为您安装了错误的( )组件matplotlibthere are the 32 bit and 64 bit components

This page provides you all binaries (32bit,64bit) for Windows.It also includes other packages apart from matplotlib if you may be needing them in the future.

此页面为您提供适用于 Windows 的所有二进制文件(32 位、64 位)。如果您将来可能需要它们,它还包括除 matplotlib 之外的其他软件包。

Try installing the proper version for your computer and it should work.

尝试为您的计算机安装正确的版本,它应该可以工作。

Also don't forget to check whether the Python version you are using is suitable for your computer (32bit or 64bit)

另外不要忘记检查您使用的Python版本是否适合您的计算机(32位或64位)

So the problem you are facing is one of these:

因此,您面临的问题是以下问题之一:

  • You have a 32 bit system, but you have installed the 64 bit component of matplotlib
  • You have a 64 bit system, but you have installed the 32 bit component of matplotlib
  • You have a 32 bit system, but you have installed the 64 bit component of Pythonitself
  • You have a 64 bit system, but you have installed the 32 but component of Pythonitself
  • 您有一个 32 位系统,但是您已经安装了 64 位组件 matplotlib
  • 你有一个 64 位系统,但你已经安装了 32 位组件 matplotlib
  • 你有一个 32 位系统,但你已经安装了Python它本身的 64 位组件
  • 您有一个 64 位系统,但您安装了 32 位但组件Python本身

If you are not sure about how your computer's processor handles information, please check THIS WEBSITE

如果您不确定计算机的处理器如何处理信息,请查看此网站

To check which version of python you have installed, refer TO THIS QUESTION IN STACKOVERFLOW

要检查您安装了哪个版本的 python,请参阅STACKOVERFLOW 中的这个问题

回答by Leandro Gomide

Just to add to ThePredator answer:

只是添加到 ThePredator 答案:

I had both32 bit and 64 bit Python 2.7 installed. When I ran python from cmd, Windows would load 32 bit python, but when trying to run something with matplotlib, this error would pop up. I have a 64 bit machine

我安装32 位和 64 位 Python 2.7。当我从 cmd 运行 python 时,Windows 会加载 32 位 python,但是当尝试使用 matplotlib 运行某些东西时,会弹出这个错误。我有一台 64 位机器

What I did to solve

我做了什么来解决

  1. Uninstall all python versions (check within Control Panel -> Programs and Resources)
  2. Install coherent versions for python ant matplotlib (32 bit python should go with 32 bit matplotlib, etc.). Most recent Python installers come with pip, so make sure Python directory is in your PATH AND just enter pip install matplotlibin a command prompt and you should be fine.
  1. 卸载所有 python 版本(在控制面板 -> 程序和资源中检查)
  2. 为 python ant matplotlib 安装连贯版本(32 位 python 应该与 32 位 matplotlib 等一起使用)。大多数最新的 Python 安装程序都带有pip,因此请确保 Python 目录在您的 PATH 中,并且只需pip install matplotlib在命令提示符中输入即可。

回答by Plory.Truck

On jupyter notebook I solved this problem by this way:

在 jupyter notebook 上,我通过这种方式解决了这个问题:

  1. Install "numpy-1.11.0b2+mkl-cp35-none-win_amd64.whl" from this page.

  2. If there is still no change, it's worth trying to reinstall matplotlib by pip.

  1. 从此页面安装“numpy-1.11.0b2+mkl-cp35-none-win_amd64.whl” 。

  2. 如果仍然没有变化,则值得尝试通过pip重新安装matplotlib。