Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt5 fails as "suitable UI Toolkit" for Mayavi with Python 3.6

I'd like to run SfePy demos but there is a problem displaying using Mayavi. See http://sfepy.org/doc-devel/installation.html#requirements

I've:

  • created an anaconda Python 3.6 environment (per this answer) using conda create --name SfePy36 python=3.6
  • installed mayavi using conda install -c conda-forge mayavi

  • installed pip3 using python3 get-pip.py (from here)

  • installed PyQt5 using pip3 install PyQt5

I don't know how to independently check that PyQt5 is or is not installed properly. If I repeat pip3 install PyQt5 it tells me it's already installed, but that doesn't mean it was done correctly or is in the right place.


When I run the very simple mayavi test below I get the following error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site- packages/mayavi/tools/sources.py", line 1162, in scalar_field
    return tools.add_dataset(data_source.m_data, name, **kwargs)
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/tools.py", line 91, in add_dataset
engine = _get_engine_from_kwarg(kwargs)
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/tools.py", line 36, in _get_engine_from_kwarg
    gcf()
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/figure.py", line 114, in gcf
engine = get_engine()
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/engine_manager.py", line 92, in get_engine
return self.new_engine()
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/engine_manager.py", line 137, in new_engine
check_backend()
  File "/Users/david/anaconda3/envs/SfePy36/lib/python3.6/site-packages/mayavi/tools/engine_manager.py", line 40, in check_backend
raise ImportError(msg)
ImportError: Could not import backend for traitsui.  Make sure you
    have a suitable UI toolkit like PyQt/PySide or wxPython
    installed.

Simple demo fails (from here):

from mayavi import mlab
import numpy as np

x, y, z = np.mgrid[-10:10:20j, -10:10:20j, -10:10:20j]
s = np.sin(x*y*z)/(x*y*z)

mlab.pipeline.volume(mlab.pipeline.scalar_field(x,y,z,s))
mlab.show()
like image 403
uhoh Avatar asked May 02 '19 08:05

uhoh


1 Answers

You may have to use wxPython instead of PyQt/PySide. Have a look at the installation guide, point number 2.

like image 162
Patol75 Avatar answered Nov 15 '22 03:11

Patol75