Pylab导入错误dll加载失败

时间:2012-02-29 23:41:25

标签: dll importerror matplotlib

当我尝试导入pylab时,我正在收到此错误,我很好奇可能会出现什么样的修复,因为linux与此机器不能很好地配合。

Microsoft Windows [Version 6.1.7601] 版权所有(c)2009 Microsoft Corporation。保留所有权利。

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:\用户\玛&GT;

1 个答案:

答案 0 :(得分:0)

您似乎对Tkinter包有问题。检查您是否安装了32位版本,因为您似乎使用的是32位Python。 如果这不起作用,您可以尝试使用不同的后端(如GTK或QT)。 要更改后端,请将其放在脚本的开头(导入pylab之前)

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

您可以更改any other backendGTKAggHere更多关于如何设置matplotlib的默认值。

希望这适合你