1

我在 Mac 上的 Eclipse 中工作。我正在使用 PyDev 版本 2.6.0.2012062818。我有一个运行完美的程序,但是在我将 Lion OS 更新为 Mountain Lion OS 后,运行时出现以下错误:

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 模块。我在站点包中没有 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__
4

2 回答 2

0

我认为当您更新时,某些文件已被替换。

在 Ubuntu 11.04 wx.VERSION_STRING 上,返回字符串值。

尝试重新安装 WX,或将“VERSION_STRING”附加到 WX 主文件。

于 2012-08-13T08:51:20.660 回答
0

我刚才遇到了类似的问题。我正在研究 Winodws 和 MacOSX。

今天,当我执行我的使用 matplotlib 和 wx 的 python 程序时,它只会弹出该消息。

我修复了: 1.我通过pip卸载了wx;2.安装wxpython;3.将matplotlib从1.2.0更新到1.2.1;

我想问题是wx我从 pip 安装的包根本不是 wx,它以某种方式覆盖了我的 wxpython 导入。

希望这些信息能给你一些关于你的问题以及其他问题的提示。

于 2013-05-22T13:35:56.727 回答