4

I'm currently receiving this error when I try to import pylab, I'm just curious as to what sort of fix there might be as linux does not cooperate well with this machine.

Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Uma>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win 32

>>> import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pylab.py", line 1, in <module>
    from matplotlib.pylab import *
File "C:\Python27\lib\site-packages\matplotlib\pylab.py", line 263, in <module>
    from matplotlib.pyplot import *
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", line 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.
>>> quit()

C:\Users\Uma>

1 Answers1

0

You seem to have a problem with the Tkinter package. Check if you have the 32bit version installed, since you seem to be using 32bit Python. If that doesn't work, you can always try using a different backend (like GTK or QT). To change the backend, put this in the beginning of you script (before importing pylab)

import matplotlib
matplotlib.rcParams['backend'] = 'GTKAgg'

You can change GTKAgg for any other backend. Here is some more on how to set the default values of matplotlib.

Hope this works for you

Community
  • 1
  • 1
Leo Uieda
  • 203
  • 2
  • 6
  • I have the same problem; even after changing the backend, `ImportError: DLL load failed: %1 is not a valid Win32 application.` still persists. – Antimony Nov 19 '13 at 22:32