1

アクセス可能なすべてのモジュールのリストを取得しようとすると、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!
4

1 に答える 1

0

を呼び出すとhelp('modules')、 で定義されているようsite.pypydoc.help()が呼び出されます。

これにより、Helper.listmodules() が呼び出さModuleScanner()れ、docstring に従って「モジュールの概要を検索する割り込み可能なスキャナー」が呼び出されます。

残念ながら、モジュールのインポートが含まれるため、すべてのモジュール/パッケージをスキャンできるわけではありません。ただし、エラーが発生するだけで幸運です。私のシステム(Linux、Python 2.7.3)では、これによりセグメンテーション違反が発生します

于 2013-03-28T06:18:56.347 に答える