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()
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
uhoh
  • 3,713
  • 6
  • 42
  • 95

1 Answers1

2

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

Patol75
  • 4,342
  • 1
  • 17
  • 28
  • I've installed it again. To the first line: `from mayavi import mlab` I get "This program needs access to the screen. Please run with a Framework build of python, and only when you are logged in on the main display of your Mac." I don't want to build a Framework (don't even know what that is) I just want to run in a normal anaconda environment. I'm on a Mac laptop and only have one screen. – uhoh May 03 '19 at 05:30
  • Oh! Re-reading your link, no that is not the procedure I followed. I just [followed this](http://sfepy.org/doc-devel/installation.html#installing-sfepy) as far as it goes. Okay I will start again from scratch and see how it goes. Thanks! – uhoh May 03 '19 at 05:39
  • Okay getting closer; `from mayavi import mlab` yields `WARNING: Imported VTK version (8.2) does not match the one use to build the TVTK classes (6.3). This may cause problems. Please rebuild TVTK.` SfePy now successfully generates a blank window https://i.stack.imgur.com/uOrbL.png and the message `File "/Users/david/anaconda3/envs/SfePy36/lib/python2.7/site-packages/tvtk/tvtk_classes.zip/tvtk_classes/havs_volume_mapper.py", line 125, in __init__ AttributeError: 'module' object has no attribute 'vtkHAVSVolumeMapper'`which contains "python2.7" *so I think there is still a problem using wxpython* – uhoh May 03 '19 at 08:52
  • ...but strangely SfePy generates an image, yay! https://i.stack.imgur.com/TRddq.png – uhoh May 03 '19 at 09:18