我有 2 台电脑(笔记本电脑和工作站),当我在笔记本电脑上运行版本检查代码时:
computer
LAPTOP
OS props
Windows-7-6.1.7601-SP1
python props
('default', 'May 15 2013 22:44:16')
python version
2.7.5
OS bit and OS type
('64bit', 'WindowsPE')
check if system is 32bit or 64bit
('7fffffffffffffff', True)
numpy version
1.7.1
matplotlib version
1.3.0
在工作站上:
computer
WORKSTATION
OS props
Windows-7-6.1.7601-SP1
python props
('default', 'May 15 2013 22:44:16')
python version
2.7.5
OS bit and OS type
('64bit', 'WindowsPE')
check if system is 32bit or 64bit
('7fffffffffffffff', True)
numpy version
1.7.1
matplotlib version
1.3.0
除了一些额外的软件包外,该软件基本相同。但是当我尝试在工作站计算机上运行以下代码时:
import numpy as np
import matplotlib
# matplotlib.use('QTAgg')
from matplotlib import pyplot as plt
我收到以下错误:
Traceback (most recent call last):
File "C:\Users\WORKSTATION\python\src\gibljiv_kontakt_E11_vzmet\preview_and_sort_measurement_data.py", line 9, in <module>
from matplotlib import pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 98, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "C:\Python27\lib\site-packages\matplotlib\backends\__init__.py", line 28, in pylab_setup
globals(),locals(),[backend_name],0)
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
我想知道什么是错误的,如何修复?如果我取消注释该行,则代码有效(它不会返回任何错误):
matplotlib.use('QTAgg')
但是当我用它来显示图时,没有显示图。任何建议有什么问题以及如何解决这个问题。我想补充一点,就像一个月前我在我的工作站计算机上更新 python 和 python 的包之前,matplotlib 工作没有问题,但现在我收到了这个错误。