python 3中的mayavi trait错误

时间:2017-03-06 15:18:13

标签: python python-3.x mayavi

我正在尝试在我的conda环境中使用Mayavi和python 3.5。到目前为止,我从http://www.lfd.uci.edu/~gohlke/pythonlibs/#vtk下载了VTK-7.1.0-cp35-cp35m-win_amd64.whl,然后运行pip install VTK-7.1.0-cp35-cp35m-win_amd64.whl。根据{{​​3}}中的建议,Mayavi安装了pip install mayavi

我尝试了the discussion here

import numpy as np
from mayavi import mlab

x = np.linspace(0,10,50)
y = np.linspace(0,15,50)
z = np.linspace(0,8,50)

X, Y, Z = np.meshgrid(x, y, z)

s = np.cos(X) + np.sin(Y) + Z**0.5
b1 = np.percentile(s, 20)
b2 = np.percentile(s, 80)
mlab.pipeline.volume(mlab.pipeline.scalar_field(s), vmin=b1, vmax=b2)
mlab.axes()
mlab.show()

得到了这个错误:

Changing backend to Qt for Mayavi

Traceback (most recent call last):

  File "<ipython-input-22-ac4779584bbe>", line 13, in <module>
    mlab.pipeline.volume(mlab.pipeline.scalar_field(s), vmin=b1, vmax=b2)

  File "C:\Users\kiritani\AppData\Local\Continuum\Anaconda3\envs\tarui\Lib\site-packages\mayavi\tools\pipe_base.py", line 38, in the_function
    factory = factory_class(*args, **kwargs)

  File "C:\Users\kiritani\AppData\Local\Continuum\Anaconda3\envs\tarui\Lib\site-packages\mayavi\tools\pipe_base.py", line 146, in __init__
    if issubclass(self._target.__class__, Filter):

  File "C:\Users\kiritani\AppData\Local\Continuum\Anaconda3\envs\tarui\Lib\site-packages\traits\trait_types.py", line 2937, in create_default_value
    return klass( *args[1:], **kw )

  File "C:\Users\kiritani\AppData\Local\Continuum\Anaconda3\envs\tarui\Lib\site-packages\mayavi\core\module.py", line 58, in __init__
    self.setup_pipeline()

  File "C:\Users\kiritani\AppData\Local\Continuum\Anaconda3\envs\tarui\Lib\site-packages\mayavi\modules\volume.py", line 318, in setup_pipeline
    available_mappers = find_volume_mappers()

  File "C:\Users\kiritani\AppData\Local\Continuum\Anaconda3\envs\tarui\Lib\site-packages\mayavi\modules\volume.py", line 53, in find_volume_mappers
    inst = klass()

  File "tvtk_classes\smart_volume_mapper.py", line 108, in __init__
    tvtk_base.TVTKBase.__init__(self, vtk.vtkSmartVolumeMapper, obj, update, **traits)

  File "C:\Users\kiritani\AppData\Local\Continuum\Anaconda3\envs\tarui\Lib\site-packages\tvtk\tvtk_base.py", line 341, in __init__
    self.update_traits()

  File "C:\Users\kiritani\AppData\Local\Continuum\Anaconda3\envs\tarui\Lib\site-packages\tvtk\tvtk_base.py", line 496, in update_traits
    setattr(self, name, val)

  File "C:\Users\kiritani\AppData\Local\Continuum\Anaconda3\envs\tarui\Lib\site-packages\traits\trait_handlers.py", line 173, in error
    value )

TraitError: The 'vector_component' trait of a SmartVolumeMapper instance must be 0 <= a long integer <= 3 or 2037150581, but a value of 255 <class 'int'> was specified.

我做错了什么?

0 个答案:

没有答案