当我试图列出所有可访问模块的列表时,Python解释器给了我一个可怕的错误(见下文)。我在谷歌上搜索了“wx”_core.pynoappror:的wx.应用程序必须先创建对象!“我还没有找到一个很好的解释来解释如何在这种情况下修复它。有人能帮我吗?在
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')
,那么按照您的site.py
中的定义,pydoc.help()
将被调用。在这将导致调用Helper.listmodules()然后根据其docstring调用
ModuleScanner()
,这是一个“搜索模块概要的可中断扫描仪”。在不幸的是,并非所有模块/软件包都能被扫描,因为这包括导入模块。你很幸运,你只是得到了一个错误。在我的系统(Linux,Python2.7.3)上,这会产生一个分段错误
相关问题 更多 >
编程相关推荐