enthought / mayavi

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

importing mayavi.mlab results in error #875

Open neramas1221 opened 4 years ago

neramas1221 commented 4 years ago

When I try and use

import mayavi.mlab

I get the following issue: No traitsui.toolkits plugin found for toolkit null

Does anyone know how to fix this?

Thank you

corranwebster commented 4 years ago

Most likely you do not have a GUI toolkit installed into your environment. You need to have one of PyQt, PySide2 or wxPython (version 3.x, currently) installed.

neramas1221 commented 4 years ago

I've installed both PyQt and PySide2 but I still get the error, i've checked my pip list and they are both installed. Do I need to set them somehow before importing?

aconceicao commented 4 years ago

I also have the same problem.

File "C:\Users\concea\AppData\Local\Continuum\anaconda3\Scripts\mayavi2-script.py", line 6, in from mayavi.scripts.mayavi2 import main File "C:\Users\concea\AppData\Local\Continuum\anaconda3\lib\site-packages\mayavi\scripts\mayavi2.py", line 427, in runtests.main() File "C:\Users\concea\AppData\Local\Continuum\anaconda3\lib\site-packages\mayavi\tests\runtests.py", line 225, in main status = m2_tests(verbose) File "C:\Users\concea\AppData\Local\Continuum\anaconda3\lib\site-packages\mayavi\tests\runtests.py", line 179, in m2_tests err = run(tests, verbose) File "C:\Users\concea\AppData\Local\Continuum\anaconda3\lib\site-packages\mayavi\tests\runtests.py", line 124, in run res = re.search('Ran\s(\d)\s*test', err) File "C:\Users\concea\AppData\Local\Continuum\anaconda3\lib\re.py", line 183, in search return _compile(pattern, flags).search(string) TypeError: cannot use a string pattern on a bytes-like object

Could anyone suggest me how to solve it? I have installed both pyqt and VTK

mdickinson commented 4 years ago

@aconceicao The traceback you show looks unrelated to the toolkit error the OP was reporting. There's a separate issue here, which is that the runtests test runner hasn't been fully updated to work with Python 3.

Huzaifg commented 3 years ago

RuntimeError: No traitsui.toolkits plugin found for toolkit null

Same error. I have PyQt5 installed On pip3 show PyQt5

Name: PyQt5
Version: 5.15.1
Summary: Python bindings for the Qt cross platform application toolkit
Home-page: https://www.riverbankcomputing.com/software/pyqt/
Author: Riverbank Computing Limited
Author-email: info@riverbankcomputing.com
License: GPL v3
Location: /home/huzaifa/env/lib/python3.8/site-packages
Requires: PyQt5-sip
Required-by: 

Also, typing mayavi2 in the cmd opens the GUI

mdickinson commented 3 years ago

@Huzaifg Thanks for the report. It would be really helpful if you could show the complete traceback, and give system information and provide exact instructions to reproduce.

Huzaifg commented 3 years ago

Hey @mdickinson! Here is the complete traceback

Exception in Tkinter callback
Traceback (most recent call last):
  File "tkinter/__init__.py", line 1883, in __call__
  File "arai.py", line 19, in plot
    from mayavi import mlab
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/huzaifa/env/lib/python3.8/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "mayavi/mlab.py", line 16, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/huzaifa/env/lib/python3.8/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "mayavi/tools/camera.py", line 24, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/huzaifa/env/lib/python3.8/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "mayavi/tools/engine_manager.py", line 12, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/huzaifa/env/lib/python3.8/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "mayavi/preferences/api.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/huzaifa/env/lib/python3.8/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "mayavi/preferences/preference_manager.py", line 29, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/huzaifa/env/lib/python3.8/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "traitsui/api.py", line 32, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/huzaifa/env/lib/python3.8/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "traitsui/editors/__init__.py", line 22, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/huzaifa/env/lib/python3.8/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "traitsui/editors/api.py", line 24, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "/home/huzaifa/env/lib/python3.8/site-packages/PyInstaller/loader/pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "traitsui/editors/code_editor.py", line 34, in <module>
  File "traitsui/editors/code_editor.py", line 46, in ToolkitEditorFactory
  File "traits/trait_factory.py", line 40, in __call__
  File "traitsui/toolkit_traits.py", line 43, in ColorTrait
  File "traitsui/toolkit.py", line 113, in toolkit
  File "pyface/base_toolkit.py", line 288, in find_toolkit
  File "pyface/base_toolkit.py", line 215, in import_toolkit
RuntimeError: No traitsui.toolkits plugin found for toolkit null

I am building an executable using Pyinstaller which uses mayavi. I have created a virtual environment using virtualenv with all the required modules installed. Mayavi opens in the virtual environment and from mayavi import mlab also runs in the environment. But when I build the executable and test it, I get this error.

mdickinson commented 3 years ago

Ah, PyInstaller. In that case the problem is likely related to https://github.com/enthought/pyface/issues/350.

dorkama commented 3 years ago

I have the same problem but am not using pyinstaller. Also, this problem only occurs when I import mlab on debug mode in pycharm (doesn't happen in a regular run, not sure what's the difference)

mdickinson commented 3 years ago

@dorkama Thanks for the report. Can you provide more information about exactly what you did, what operating system you're using, what versions of Python, Mayavi, VTK and other packages you're using, where you got them from, and exactly what results you got (including any relevant tracebacks)? We'd be happy to help, but there are many variables here and it's hard to diagnose or reproduce your issue without more information.

simulatio commented 3 years ago

Happens also in VS code debug mode.