Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing MatPlotLib in windows

I can't seem to get MatPlotLib to work. I downloaded and installed the correct version (matplotlib-1.1.0.win32-py2.7.exe), and I already have numpy and scipy installed (and they work with no problems).

This is the error that I get:

C:\python code>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 95, in <module>
    new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "C:\Python27\lib\site-packages\matplotlib\backends\__init__.py", line 25,
 in pylab_setup
    globals(),locals(),[backend_name])
  File "C:\Python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", lin
e 8, in <module>
    import Tkinter as Tk, FileDialog
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 38, in <module>
    import FixTk
  File "C:\Python27\lib\lib-tk\FixTk.py", line 65, in <module>
    import _tkinter
ImportError: DLL load failed: %1 is not a valid Win32 application.
>>>

Any ideas?

like image 772
Zach Avatar asked Jun 04 '12 15:06

Zach


2 Answers

This problem occurs when you have a previous 64-bit version of python that was incorrectly uninstalled.

Uninstalling both versions of python correctly, and then reinstalling 32-bit python fixed the problem.

like image 69
Zach Avatar answered Oct 08 '22 16:10

Zach


Zach the best way to install matplotlib in windows is to go for Python(x,y) as a Bundle. All the dependencies are solved, and you get a really cool IDE and the full documentation.

See Python(x,y) here,

like image 31
oz123 Avatar answered Oct 08 '22 17:10

oz123