Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

>>> 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.

like image 695
RAMAKRISHNA REDDY Avatar asked Oct 29 '14 19:10

RAMAKRISHNA REDDY


2 Answers

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).

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.

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)

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 Python itself
  • You have a 64 bit system, but you have installed the 32 but component of Python itself

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

like image 116
Srivatsan Avatar answered Nov 19 '22 04:11

Srivatsan


Just to add to ThePredator answer:

I had both 32 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

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 matplotlib in a command prompt and you should be fine.
like image 23
Leandro Gomide Avatar answered Nov 19 '22 03:11

Leandro Gomide