Mayavi: No module named 'importlib_resources' for Python 3.8

Created on 9 Jan 2021  ·  4Comments  ·  Source: enthought/mayavi

Installed with conda 4.8.2 on Python 3.8, the import fails:

Python 3.8.6 | packaged by conda-forge | (default, Oct  7 2020, 18:42:56)
[Clang 10.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from mayavi import mlab
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/mayavi/mlab.py", line 16, in <module>
    from mayavi.tools.camera import view, roll, yaw, pitch, move
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/mayavi/tools/camera.py", line 24, in <module>
    from .engine_manager import get_engine
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/mayavi/tools/engine_manager.py", line 12, in <module>
    from mayavi.preferences.api import preference_manager
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/mayavi/preferences/api.py", line 4, in <module>
    from .preference_manager import preference_manager
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/mayavi/preferences/preference_manager.py", line 29, in <module>
    from traitsui.api import View, Group, Item
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/traitsui/api.py", line 35, in <module>
    from .editors.api import (
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/traitsui/editors/__init__.py", line 26, in <module>
    from .api import (
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/traitsui/editors/api.py", line 45, in <module>
    from .list_str_editor import ListStrEditor
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/traitsui/editors/list_str_editor.py", line 29, in <module>
    from pyface.image_resource import ImageResource
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/pyface/image_resource.py", line 19, in <module>
    ImageResource = toolkit_object("image_resource:ImageResource")
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/pyface/base_toolkit.py", line 152, in __call__
    module = import_module(mname, package)
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/pyface/ui/qt4/image_resource.py", line 25, in <module>
    from pyface.i_image_resource import IImageResource, MImageResource
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/pyface/i_image_resource.py", line 14, in <module>
    from pyface.resource_manager import resource_manager
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/pyface/resource_manager.py", line 14, in <module>
    from pyface.resource.api import ResourceManager
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/pyface/resource/api.py", line 13, in <module>
    from .resource_manager import ResourceManager
  File "/Users/scott/opt/anaconda3/envs/mapping/lib/python3.8/site-packages/pyface/resource/resource_manager.py", line 20, in <module>
    from importlib_resources import files
ModuleNotFoundError: No module named 'importlib_resources'

I think this may be related to the Python 3.9 support, as running
pip install importlib-resources
fixes the problem (found on https://pypi.org/project/importlib-resources/).

I'm not sure what the preferred way to fix this would be, or I would contribute the PR.

Most helpful comment

I think it's not mayavi's bug, though, but instead conda-forge's packaging of pyface, so this should be the right issue to watch:

https://github.com/conda-forge/pyface-feedstock/pull/27

All 4 comments

For some reason your install of Pyface is not picking up the dependency on importlib_resources (and possibly also importlib_metadata). If you use pip or edm they should install correctly, but it looks like you are using conda so you should report this as an issue to whoever is providing your Pyface builds.

If you are using pip to install Pyface (or Mayavi), please report this as an issue on the Pyface repo!

I am going to close this, as it is not a direct issue with Mayavi.

Your package doesn't work with conda correctly
You shouldn't just close issue/your eyes on it

I think it's not mayavi's bug, though, but instead conda-forge's packaging of pyface, so this should be the right issue to watch:

https://github.com/conda-forge/pyface-feedstock/pull/27

Thanks @larsoner for pointing out the issue in conda-forge. Hopefully your PR gets merged soon!

Was this page helpful?
0 / 5 - 0 ratings