enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 285 forks source link

mlab import fails on macOS 11 Py3.9 #1028

Open max3-2 opened 3 years ago

max3-2 commented 3 years ago

Hi,

I am currently trying to get mayavi to work under a macOS 11 / Python 3.9 env. Since there are no wheels available, I built vtk from master myself, so im getting vtk==9.0.20210422. I can subsequently import vtk and also install mayavi from either master (python setup.py bdist_wheel) or just pip install mayavi with no apparent errors.

I can then start mayavi2 with just some warnings (cant make much of that honestly):

multiple 'traitsui.toolkits' plugins found for toolkit 'qt4': traitsui.qt4, traitsui.qt4
multiple 'tvtk.toolkits' plugins found for toolkit 'qt4': tvtk.pyface.ui.qt4.init, tvtk.pyface.ui.qt4.init

However, trying a from mayavi import mlab yields the traceback below. I just scanned the issues and following #939 this should (?) be resolved, however it is not for me...Is this fix incoming and not merged or is this a new bug?

----> 1 from mayavi import mlab

/usr/local/lib/python3.9/site-packages/mayavi/mlab.py in <module>
     32 
     33 
---> 34 from .tools.helper_functions import contour3d, test_contour3d, \
     35     quiver3d, test_quiver3d, test_quiver3d_2d_data, \
     36     points3d, test_points3d, test_molecule, \

/usr/local/lib/python3.9/site-packages/mayavi/tools/helper_functions.py in <module>
     14 # License: BSD Style.
     15 
---> 16 from .modules import VectorsFactory, StreamlineFactory, GlyphFactory, \
     17             IsoSurfaceFactory, SurfaceFactory, ContourSurfaceFactory, \
     18             ImageActorFactory, ImagePlaneWidgetFactory, glyph_mode_dict

/usr/local/lib/python3.9/site-packages/mayavi/tools/modules.py in <module>
     25 from . import tools
     26 from .pipe_base import PipeFactory, make_function
---> 27 from .filters import new_class
     28 
     29 

/usr/local/lib/python3.9/site-packages/mayavi/tools/filters.py in <module>
     16 from tvtk.common import camel2enthought
     17 from tvtk.api import tvtk
---> 18 import mayavi.filters.api as filters
     19 from mayavi.core.registry import registry
     20 from .pipe_base import PipeFactory, make_function

/usr/local/lib/python3.9/site-packages/mayavi/filters/api.py in <module>
     17 from .elevation_filter import ElevationFilter
     18 from .extract_edges import ExtractEdges
---> 19 from .extract_grid import ExtractGrid
     20 from .extract_tensor_components import ExtractTensorComponents
     21 from .extract_unstructured_grid import ExtractUnstructuredGrid

/usr/local/lib/python3.9/site-packages/mayavi/filters/extract_grid.py in <module>
     13 
     14 from tvtk.api import tvtk
---> 15 from tvtk.vtk_module import VTK_MAJOR_VERSION
     16 
     17 # Local imports

ImportError: cannot import name 'VTK_MAJOR_VERSION' from 'tvtk.vtk_module' (/usr/local/lib/python3.9/site-packages/tvtk/vtk_module.py)
max3-2 commented 3 years ago

Regarding

I can then start mayavi2 with just some warnings (cant make much of that honestly):

multiple 'traitsui.toolkits' plugins found for toolkit 'qt4': traitsui.qt4, traitsui.qt4
multiple 'tvtk.toolkits' plugins found for toolkit 'qt4': tvtk.pyface.ui.qt4.init, tvtk.pyface.ui.qt4.init

This seems to be baked into pyface entry points being doubled. Any insight? Does not seem critical but maybe should be fixed. plugins in pyface/base_toolkit l. 217 has

[EntryPoint(name='qt4', value='pyface.ui.qt4.init:toolkit_object', group='pyface.toolkits'), EntryPoint(name='qt4', value='pyface.ui.qt4.init:toolkit_object', group='pyface.toolkits')]

with

 importlib_metadata.entry_points()['pyface.toolkits']
(EntryPoint(name='null', value='pyface.ui.null.init:toolkit_object', group='pyface.toolkits'),
EntryPoint(name='qt', value='pyface.ui.qt4.init:toolkit_object', group='pyface.toolkits'),
EntryPoint(name='qt4', value='pyface.ui.qt4.init:toolkit_object', group='pyface.toolkits'),
EntryPoint(name='wx', value='pyface.ui.wx.init:toolkit_object', group='pyface.toolkits'),
EntryPoint(name='null', value='pyface.ui.null.init:toolkit_object', group='pyface.toolkits'),
EntryPoint(name='qt', value='pyface.ui.qt4.init:toolkit_object', group='pyface.toolkits'),
EntryPoint(name='qt4', value='pyface.ui.qt4.init:toolkit_object', group='pyface.toolkits'),
EntryPoint(name='wx', value='pyface.ui.wx.init:toolkit_object', group='pyface.toolkits'))
rogerwarburton commented 3 years ago

I see this too. Standard pip installs on OS X 11.4 Big Sur: Python 3.9; mayavi 4.7.3; vtk 9.0.20210612.dev() from mayavi import mlab -- hangs immediately import mayavi -- runs but fails at mayavi.mlab.clf() # Clear figure AttributeError: module 'mayavi' has no attribute 'mlab'