【问题标题】:Python 2.5 interpreter is throwing a PyNoAppError when I run >>>> help('modules')当我运行 >>>> help('modules') 时,Python 2.5 解释器抛出 PyNoAppError
【发布时间】:2012-04-05 07:39:54
【问题描述】:

当我尝试拉出所有可访问模块的列表时,我的 Python 解释器给了我一个丑陋的错误(见下文)。我用谷歌搜索了“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!

【问题讨论】:

  • 我其实知道错误/异常,但是help("modules")没有理由应该抛出一个。
  • 错误。向他们报告。他们不应该在导入时运行这样的代码。

标签: python wxpython python-2.5


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-07
    • 1970-01-01
    • 1970-01-01
    • 2020-10-11
    • 2019-12-24
    • 2022-11-30
    • 1970-01-01
    • 2016-12-07
    相关资源
    最近更新 更多