当我运行>>>>时,Python 2.5解释器抛出一个PyNoAppError。帮助(“模块”)

时间:2012-04-05 07:39:54

标签: python wxpython python-2.5

当我尝试提取所有可访问模块的列表时,我的Python解释器给了我一个难看的错误(见下文)。我用Google搜索了“wx._core.PyNoAppError:必须首先创建wx.App对象!”我没有找到一个很好的解释如何在这种情况下修复它。任何人都可以帮助我吗?

Python 2.5.4 (r254:67916, Aug  1 2011, 15:52:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>>> help('modules')

Please wait a moment while I gather a list of all available modules...

/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pkgutil.py:110: DeprecationWarning: twisted.flow is unmaintained.
  __import__(name)
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/twisted/words/im/__init__.py:8: UserWarning: twisted.im will be undergoing a rewrite at some point in the future.
  warnings.warn("twisted.im will be undergoing a rewrite at some point in the future.")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site.py", line 348, in __call__
    return pydoc.help(*args, **kwds)
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py", line 1645, in __call__
    self.help(request)
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py", line 1682, in help
    elif request == 'modules': self.listmodules()
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py", line 1803, in listmodules
    ModuleScanner().run(callback)
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pydoc.py", line 1854, in run
    for importer, modname, ispkg in pkgutil.walk_packages():
  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pkgutil.py", line 110, in walk_packages
    __import__(name)
  File "/var/tmp/wxWidgets/wxWidgets-13~231/2.5/DSTROOT/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wxaddons/__init__.py", line 29, in <module>
  File "/var/tmp/wxWidgets/wxWidgets-13~231/2.5/DSTROOT/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac-unicode/wx/_misc.py", line 3298, in __init__
wx._core.PyNoAppError: The wx.App object must be created first!

1 个答案:

答案 0 :(得分:0)

如果您拨打help('modules'),则按照site.py中的定义调​​用pydoc.help()

这导致调用Helper.listmodules(),然后根据其文档字符串调用ModuleScanner(),即“可搜索模块概要的可中断扫描程序”。

不幸的是,并非所有模块/包都能够被扫描,因为这包括导入模块。然而,你很幸运,你只是得到一个错误。在我的系统(Linux,Python 2.7.3)上,这会产生分段错误