ModuleNotFoundError: No module named 'traitsui.qt4.editor' when running mayavi/examples/mayavi/interactive/lorenz_ui.py
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 316
- Avg merge
- 7h 44m
- Merged PRs (30d)
- 5
Description
When running mayavi/examples/mayavi/interactive/lorenz_ui.py, ModuleNotFoundError: No module named 'traitsui.qt4.editor' will be raised. This is probably due to mayavi haven't adapted to the update of qt renaming in traitsui
Replication: python3.11 mayavi/examples/mayavi/interactive/lorenz_ui.py
Trace:
```
(py311) (base) cyliu@aus552cyliu mayavi % python3.11 examples/mayavi/interactive/lorenz_ui.py
/Users/cyliu/Documents/3.11_test/mayavi/tvtk/pyface/ui/qt4/scene_editor.py:16: FutureWarning: The traitsui.qt4.* modules have moved to traitsui.qt.*.
Applications which require backwards compatibility can either:
- set the ETS_QT4_IMPORTS environment variable
- set the ETS_TOOLKIT environment variable to "qt4",
- the ETSConfig.toolkit to "qt4"
- install a ShadowedModuleFinder into sys.meta_path::
import sys
from pyface.ui import ShadowedModuleFinder
sys.meta_path.append(ShadowedModuleFinder(
package="traitsui.qt4.",
true_package="traitsui.qt.",
))
from traitsui.qt4.editor import Editor
Traceback (most recent call last):
File "/Users/cyliu/Documents/3.11_test/mayavi/examples/mayavi/interactive/lorenz_ui.py", line 24, in
from mayavi.core.ui.api import MayaviScene, MlabSceneModel, \
File "/Users/cyliu/Documents/3.11_test/mayavi/mayavi/core/ui/api.py", line 4, in
from tvtk.pyface.scene_editor import SceneEditor
File "/Users/cyliu/Documents/3.11_test/mayavi/tvtk/pyface/scene_editor.py", line 12, in
SceneEditor = toolkit_object('scene_editor:SceneEditor')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cyliu/Documents/3.11_test/pyface/pyface/base_toolkit.py", line 127, in __call__
module = import_module(mname, package)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/cyliu/Documents/3.11_test/mayavi/tvtk/pyface/ui/qt4/scene_editor.py", line 16, in
from traitsui.qt4.editor import Editor
ModuleNotFoundError: No module named 'traitsui.qt4.editor'
```
Link: https://github.com/enthought/mayavi/blob/master/examples/mayavi/interactive/lorenz_ui.py
Env: MacOS, python3.11
Package Version Editable project location
------------------ ----------- -----------------------------------------
apptools 5.2.0
attrdict 2.0.1
attrdict3 2.0.2
blosc2 2.0.0
celiagg 2.1.3
certifi 2022.12.7
chaco 5.1.0 /Users/cyliu/Documents/3.11_test/chaco
charset-normalizer 3.1.0
configobj 5.0.8
contourpy 1.0.7
cPython 0.0.6
cycler 0.11.0
Cython 0.29.34
dnspython 2.3.0
enable 5.4.0.dev38 /Users/cyliu/Documents/3.11_test/enable
envisage 7.0.3
fonttools 4.39.2
h5py 3.8.0
idna 3.4
joblib 1.2.0
kiwisolver 1.4.4
matplotlib 3.7.1
mayavi 4.8.2.dev0 /Users/cyliu/Documents/3.11_test/mayavi
msgpack 1.0.5
numexpr 2.8.4
numpy 1.24.2
packaging 23.1
pandas 1.5.3
Pillow 9.4.0
pip 23.1
py-cpuinfo 9.0.0
PyAudio 0.2.13
pyface 8.0.0 /Users/cyliu/Documents/3.11_test/pyface
pygarrayimage 1.0
pyglet 2.0.5 /Users/cyliu/Documents/3.11_test/pyglet
Pygments 2.14.0
pymongo 4.3.3
pyparsing 3.0.9
PySide6 6.4.3
PySide6-Addons 6.4.3
PySide6-Essentials 6.4.3
python-dateutil 2.8.2
pythonw 3.0.3
pytz 2023.2
reportlab 3.6.12
requests 2.28.2
scikit-learn 1.2.2
scipy 1.10.1
setuptools 65.6.3
shiboken6 6.4.3
six 1.16.0
tables 3.8.0
threadpoolctl 3.1.0
traits 6.4.1
traitsui 8.0.0.dev0 /Users/cyliu/Documents/3.11_test/traitsui
urllib3 1.26.15
vtk 9.2.6
wxPython 4.2.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with tvtk/pyface/ui/qt4/scene_editor.py, which imports the missing traitsui.qt4.editor module, and compare it with the traitsui.qt.* relocation shown in the warning. Reproduce the failure by running mayavi/examples/mayavi/interactive/lorenz_ui.py with Python 3.11. Done means the example starts without ModuleNotFoundError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100