当我使用 mayavi (4.3.1( 可视化网格时,它会发出以下警告:
警告:导入的 VTK 版本 (5.1( 与使用的版本不匹配 构建 TVTK 类 (6.3(。这可能会导致问题。 请重建TVTK。
我的系统:微软视窗 7 64 位, 蟒蛇 4.3.1 (最新版本(,
<code>
$ conda list qt
# packages in environment at C:ProgramDataAnaconda2:
#
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:ProgramDataAnaconda2:
#
vtk 5.10.1 py27_0 anaconda
$ conda list mayavi
# packages in environment at C:ProgramDataAnaconda2:
#
mayavi 4.5.0 <pip>
</code>
我搜索了论坛,但大多数答案都将其视为 4 年前 VTK 中的一个错误,例如,Mayavi(Python(中的 TVTK 错误。我不确定它是否有确定的解决方案。在我的电脑中,确实有另一个版本的VTK(版本>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:ProgramDataAnaconda2libsite-packagesspyderutilssitesitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:ProgramDataAnaconda2libsite-packagesspyderutilssitesitecustomize.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:ProgramDataAnaconda2libsite-packagesmayavitoolsfigure.py", line 85, in figure
engine.new_scene(name=name, size=size)
File "C:ProgramDataAnaconda2libsite-packagesapptoolsscriptingrecordable.py", line 45, in _wrapper
result = func(*args, **kw)
File "C:ProgramDataAnaconda2libsite-packagesmayavicoreengine.py", line 452, in new_scene
viewer = self.scene_factory(**factory_kwargs)
File "C:ProgramDataAnaconda2libsite-packagesmayavicoreuimayavi_scene.py", line 89, in viewer_factory
viewer.open()
File "C:ProgramDataAnaconda2libsite-packagespyfacei_window.py", line 166, in open
self._create()
File "C:ProgramDataAnaconda2libsite-packagespyfaceuiqt4application_window.py", line 121, in _create
contents = self._create_contents(self.control)
File "C:ProgramDataAnaconda2libsite-packagestvtktoolsivtk.py", line 404, in _create_contents
self.scene = self._scene_factory(parent)
File "C:ProgramDataAnaconda2libsite-packagesmayavicoreuimayavi_scene.py", line 68, in mayavi_scene_factory
s = MayaviScene(parent, stereo=p['stereo'])
File "C:ProgramDataAnaconda2libsite-packagestvtkpyfaceuiqt4decorated_scene.py", line 59, in __init__
super(DecoratedScene, self).__init__(parent, **traits)
File "C:ProgramDataAnaconda2libsite-packagestvtkpyfaceuiqt4scene.py", line 325, in __init__
self.picker = picker.Picker(self)
File "C:ProgramDataAnaconda2libsite-packagestvtkpyfacepicker.py", line 260, in __init__
configure_input(self.p_mapper, self.p_source)
File "C:ProgramDataAnaconda2libsite-packagestvtkcommon.py", line 88, in configure_input
inp.input = op.output
File "C:ProgramDataAnaconda2libsite-packagestraitstrait_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>
经过 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接口的内在错误。
主要关切
- 在我的笔记本电脑中,确实相同的安装(与上面的帖子相同(工程。我不知道为什么。
- 在我的 PC 中,在达到解决方法之前,当我康达直接安装了VTK-6,它不起作用并提示"...缺少模块"(抱歉我没有记录这些错误(。