我在Mac上的Eclipse工作。我使用PyDev版本2.6.0.2012062818。我有一个运行完美的程序,但在我将Lion操作系统更新到Mountain Lion操作系统后,我在运行时遇到以下错误:
Traceback (most recent call last):
File "/Users/Mihails/Projects/memsim/src/memsim/memsim.py", line 7, in <module>
from simulation import SimulationHP
File "/Users/Mihails/Projects/memsim/src/memsim/simulation.py", line 9, in <module>
import matplotlib.pyplot as plt
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/pyplot.py", line 95, in <module>
new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/backends/backend_wxagg.py", line 23, in <module>
import backend_wx # already uses wxversion.ensureMinimal('2.8')
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/backends/backend_wx.py", line 63, in <module>
backend_version = wx.VERSION_STRING
AttributeError: 'module' object has no attribute 'VERSION_STRING'
我根本不懂wx模块。我在site-packages中没有wx文件夹。我有wxPython。 wxPython init.py文件:
# The "old" wxPython package
import warnings
warnings.warn(
"The wxPython compatibility package is no longer automatically generated "
"or actively maintained. Please switch to the wx package as soon as possible.",
DeprecationWarning, stacklevel=2)
# We need to be able to import from the wx package, but there is also
# a wxPython.wx module and that would normally be chosen first by
# import statements. So instead we'll have a wxPython._wx module and
# then stuff it into sys.modules with a wxPython.wx alias so old
# programs will still work.
import _wx
import sys
sys.modules['wxPython.wx'] = _wx
wx = _wx
del sys
from wx import __version__
答案 0 :(得分:0)
我认为在您更新时,某些文件已被替换。
在Ubuntu 11.04 wx.VERSION_STRING上,返回字符串值。
尝试重新安装WX,或将'VERSION_STRING'附加到WX主文件。
答案 1 :(得分:0)
我刚才遇到过类似的问题。我正在研究Winodws和MacOSX。
今天当我执行使用matplotlib和wx的python程序时,它只会弹出该消息。
我修复: 我通过pip卸载了wx; 2.安装wxpython; 3.将matplotlib从1.2.0更新为1.2.1;
我想问题是我从pip安装的包wx
根本不是wx而且它以某种方式覆盖了我的wxpython导入。
希望这些信息可以为您提供一些问题以及其他问题。