Python / Mayavi / VTK错误:导入的VTK版本与TVTK类不匹配

时间:2017-03-22 15:41:49

标签: python visualization vtk mayavi

当我使用mayavi(4.3.1)可视化网格时,它会发出以下警告:

警告:导入的VTK版本(5.1)与使用的版本不匹配          建立TVTK课程(6.3)。这可能会导致问题。          请重建TVTK。

我的系统: MS Windows 7 64位,Anaconda 4.3.1(最新版本),

<code>
$ conda list qt
# packages in environment at C:\ProgramData\Anaconda2:
#
pyqt                      4.11.4                   py27_7    anaconda
qt                        4.8.7                     vc9_9  [vc9]  anaconda
qtawesome                 0.4.3                    py27_0
qtconsole                 4.2.1                    py27_0    anaconda
qtpy                      1.2.1                    py27_0

$ conda list vtk
# packages in environment at C:\ProgramData\Anaconda2:
#
vtk                       5.10.1                   py27_0    anaconda

$ conda list mayavi
# packages in environment at C:\ProgramData\Anaconda2:
#
mayavi                    4.5.0                     <pip>
</code>

我搜索了论坛,但大多数答案都认为它是4年前VTK中的一个错误,例如TVTK Error in Mayavi (Python)。我不确定它是否有一个坚定的解决方案。在我的计算机中,确实有另一个版本的VTK(版本&gt; 6),但它是用C ++编写的,与python和Mayavi没有任何关系。

我运行Maya示例代码时遇到的错误如下(由于我的VTK是5.10(如上所述),警告消息非常混乱,而且版本5.1的位置很奇怪),

<code>
>>> runfile('D:/flex_8state/code/spherical_harmonics.py', wdir='D:/flex_8state/code')
********************************************************************************
WARNING: Imported VTK version (5.1) does not match the one used
         to build the TVTK classes (6.3). This may cause problems.
         Please rebuild TVTK.
********************************************************************************

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\ProgramData\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
    execfile(filename, namespace)
  File "C:\ProgramData\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)
  File "D:/flex_8state/code/spherical_harmonics.py", line 36, in <module>
    mlab.figure(1, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0), size=(400, 300))
  File "C:\ProgramData\Anaconda2\lib\site-packages\mayavi\tools\figure.py", line 85, in figure
    engine.new_scene(name=name, size=size)
  File "C:\ProgramData\Anaconda2\lib\site-packages\apptools\scripting\recordable.py", line 45, in _wrapper
    result = func(*args, **kw)
  File "C:\ProgramData\Anaconda2\lib\site-packages\mayavi\core\engine.py", line 452, in new_scene
    viewer = self.scene_factory(**factory_kwargs)
  File "C:\ProgramData\Anaconda2\lib\site-packages\mayavi\core\ui\mayavi_scene.py", line 89, in viewer_factory
    viewer.open()
  File "C:\ProgramData\Anaconda2\lib\site-packages\pyface\i_window.py", line 166, in open
    self._create()
  File "C:\ProgramData\Anaconda2\lib\site-packages\pyface\ui\qt4\application_window.py", line 121, in _create
    contents = self._create_contents(self.control)
  File "C:\ProgramData\Anaconda2\lib\site-packages\tvtk\tools\ivtk.py", line 404, in _create_contents
    self.scene = self._scene_factory(parent)
  File "C:\ProgramData\Anaconda2\lib\site-packages\mayavi\core\ui\mayavi_scene.py", line 68, in mayavi_scene_factory
    s = MayaviScene(parent, stereo=p['stereo'])
  File "C:\ProgramData\Anaconda2\lib\site-packages\tvtk\pyface\ui\qt4\decorated_scene.py", line 59, in __init__
    super(DecoratedScene, self).__init__(parent, **traits)
  File "C:\ProgramData\Anaconda2\lib\site-packages\tvtk\pyface\ui\qt4\scene.py", line 325, in __init__
    self.picker = picker.Picker(self)
  File "C:\ProgramData\Anaconda2\lib\site-packages\tvtk\pyface\picker.py", line 260, in __init__
    configure_input(self.p_mapper, self.p_source)
  File "C:\ProgramData\Anaconda2\lib\site-packages\tvtk\common.py", line 88, in configure_input
    inp.input = op.output
  File "C:\ProgramData\Anaconda2\lib\site-packages\traits\trait_handlers.py", line 104, in _read_only
    name, class_of( object ) )
traits.trait_errors.TraitError: The 'input' trait of a PolyDataMapper instance is 'read only'.
</code>

1 个答案:

答案 0 :(得分:3)

经过3天的艰苦努力,我找到了一个解决方法,我在这里发布了对类似的受害者有所帮助。我强烈建议Mayavi / TVTK的开发人员更加关注这个错误。

这篇文章对我很有帮助,https://github.com/ContinuumIO/anaconda-issues/issues/1510。相同的初始安装,然后更新(我的初始帖子)VTK从5到6,如https://repo.continuum.io/pkgs/free/win-64/中所列。基于python / VTK版本的改变的SetInputConnection / SetInputData接口的内在错误。

主要关注点

  1. 在我的笔记本电脑中,确实安装了相同的装置(如上面的帖子) 作品。我不知道为什么。
  2. 在我的电脑中,在达成解决方法之前,当我 通过conda直接安装VTK-6,它没有工作和提示 &#34; ...缺少模块&#34; (抱歉,我没有记录这些错误)。