0

我正在尝试在 python 的蜘蛛环境中加载包 enthought.mayavi.mlab:

import enthought.mayavi.mlab as mlb

我收到以下错误消息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 487, in runfile
    execfile(filename, namespace)
  File "C:\Users\Eytan\Desktop\Mah\PyBrainTraining.py", line 2, in <module>
    import enthought.mayavi.mlab as mlb
  File "C:\Python27\lib\site-packages\enthought\mayavi\mlab.py", line 3, in <module>
    from mayavi.mlab import *
  File "C:\Python27\lib\site-packages\mayavi\mlab.py", line 27, in <module>
    from mayavi.tools.camera import view, roll, yaw, pitch, move
  File "C:\Python27\lib\site-packages\mayavi\tools\camera.py", line 25, in <module>
    from engine_manager import get_engine
  File "C:\Python27\lib\site-packages\mayavi\tools\engine_manager.py", line 12, in <module>
    from mayavi.preferences.api import preference_manager
  File "C:\Python27\lib\site-packages\mayavi\preferences\api.py", line 4, in <module>
    from preference_manager import preference_manager
  File "C:\Python27\lib\site-packages\mayavi\preferences\preference_manager.py", line 29, in <module>
    from traitsui.api import View, Group, Item
  File "C:\Python27\lib\site-packages\traitsui\api.py", line 35, in <module>
    from .editors.api import (ArrayEditor, BooleanEditor, ButtonEditor,
  File "C:\Python27\lib\site-packages\traitsui\editors\__init__.py", line 22, in <module>
    from .api import (toolkit, ArrayEditor, BooleanEditor, ButtonEditor,
  File "C:\Python27\lib\site-packages\traitsui\editors\api.py", line 10, in <module>
    from .code_editor import CodeEditor
  File "C:\Python27\lib\site-packages\traitsui\editors\code_editor.py", line 36, in <module>
    class ToolkitEditorFactory ( EditorFactory ):
  File "C:\Python27\lib\site-packages\traitsui\editors\code_editor.py", line 48, in ToolkitEditorFactory
    mark_color = Color( 0xECE9D8 )
  File "C:\Python27\lib\site-packages\traits\traits.py", line 487, in __call__
    return self.maker_function( *args, **metadata )
  File "C:\Python27\lib\site-packages\traits\traits.py", line 1183, in Color
    return ColorTrait( *args, **metadata )
  File "C:\Python27\lib\site-packages\traitsui\toolkit_traits.py", line 7, in ColorTrait
    return toolkit().color_trait( *args, **traits )
  File "C:\Python27\lib\site-packages\traitsui\toolkit.py", line 109, in toolkit
    _toolkit = _import_toolkit(ETSConfig.toolkit)
  File "C:\Python27\lib\site-packages\traitsui\toolkit.py", line 51, in _import_toolkit
    return __import__( name, globals=globals(), level=1 ).toolkit
  File "C:\Python27\lib\site-packages\traitsui\qt4\__init__.py", line 18, in <module>
    import pyface.qt
  File "C:\Python27\lib\site-packages\pyface\qt\__init__.py", line 35, in <module>
    prepare_pyqt4()
  File "C:\Python27\lib\site-packages\pyface\qt\__init__.py", line 17, in prepare_pyqt4
    sip.setapi('QString', 2)
ValueError: API 'QString' has already been set to version 1

有人知道如何解决吗?编辑:如果有帮助,我认为问题已在最后一栏中得到解释:

ValueError: API 'QString' has already been set to version 1

编辑:我尝试将 QString 和 QVariant 对象的 API 选择更改为 Api #1、#2。没有帮助。尝试将“忽略 API 更改错误”设置为 true,但没有帮助。尝试从 'qt4' 到 'wx' 的 EST_TOOLKIT。

4

1 回答 1

0

可能是因为蜘蛛本身使用了 QT 库并且已经对其进行了初始化。根据这个http://pythonhosted.org/spyder/installation.html你可以使用 PySide 而不是 PyQt4 (但我不知道这是一个配置选项还是一个后备)。

于 2013-05-23T08:39:14.087 回答