0

I am trying to use Mayavi with python 3.5 in my conda environment. So far, I downloaded VTK-7.1.0-cp35-cp35m-win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#vtk, and then ran pip install VTK-7.1.0-cp35-cp35m-win_amd64.whl. Mayavi was installed with pip install mayavi, as suggested in the discussion here.

I tried this example:

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()

And got this error:

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.

What am I doing wrong?

2
  • Using mayavi requires a compatible set of vtk, pyvtk and the traits/mayavi library. Most often this is achieved by using a package manager. Have you tried, for instance, conda install -c anaconda mayavi=4.5.0 anaconda.org/anaconda/mayavi As you are using conda, it would make sense to take profit of it. Commented Mar 7, 2017 at 23:11
  • I tried that of course, but it did not go through in my python 3.5 env. conda info mayavi says mayavi 4.5.0 is dependent on python 2.7. I was looking for a workaround. Commented Mar 8, 2017 at 15:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.