Mayavi: 'Could not import backend for traits' with Pyqt4 and mac os 10.10.5

Created on 16 Nov 2016  ·  4Comments  ·  Source: enthought/mayavi

So I tried many ways (pip, conda, easy_install, python setup develop source_code) to install mayavi, with pyqt4 and all other dependences (traits, traitsui, pyface, apptools, envisage) installed with conda, on mac os 10.10.5, but there is always an error that:

(mayavi2) ➜ mayavi git:(master) ✗ mayavi2
Traceback (most recent call last):
File "/Users/penny/anaconda/envs/mayavi2/bin/mayavi2", line 6, in
sys.exit(main())
File "/Users/penny/anaconda/envs/mayavi2/lib/python2.7/site-packages/mayavi/scripts/mayavi2.py", line 646, in main
'''
ImportError: Could not import backend for traits
Make sure that you have either the TraitsBackendWx or the TraitsBackendQt
projects installed. If you installed Mayavi with easy_install, try easy_install
. easy_install Mayavi[app] will also work.

I tried to install TraitsBackendQt but there is no matching package on current osx-64 , any suggestions on making it work? Many thanks!

Most helpful comment

@zangcc0474 "The graph"? You need to be way more specific when asking questions :)
mlab.init_notebook() is a setup command. It tells mlab that in order to plot anything, it needs to use the x3d software to plot. The message you get is confirmation that it has started correctly.

The following code should give you a inline, interactive plot when used in the notebook. It will likely be a bit slow. Please let me know if it works.

from mayavi import mlab
mlab.init_notebook()
mlab.test_contour3d()

The equivalent when run in the qtconsole, will be much faster:

from mayavi import mlab
%gui qt
mlab.test_contour3d()

All 4 comments

To force a particular backend you can specify with with the ETS_TOOLKIT environment variable. Eg. at the commandline on unix the command ETS_TOOLKIT=qt4 mayavi will run Mayavi under qt4 with either the pyside or pyqt backend.

If that doesn't work, then you have some problem with your installation, and a clean install of mayavi and dependencies may be required. The Mayavi which comes with Enthought's free Canopy python environment is known to work.

@PennyQ Were you trying to plot in the Jupyter Notebook? I was running into this issue again and again as well. Turns out you have to run mlab.init_notebook() in the notebook, or %gui qt in the qtconsole.

@thomasaarholt But after adding mlab.init_notebook(), it shows "Notebook initialized with x3d backend.". Where can I look at the graph?

@zangcc0474 "The graph"? You need to be way more specific when asking questions :)
mlab.init_notebook() is a setup command. It tells mlab that in order to plot anything, it needs to use the x3d software to plot. The message you get is confirmation that it has started correctly.

The following code should give you a inline, interactive plot when used in the notebook. It will likely be a bit slow. Please let me know if it works.

from mayavi import mlab
mlab.init_notebook()
mlab.test_contour3d()

The equivalent when run in the qtconsole, will be much faster:

from mayavi import mlab
%gui qt
mlab.test_contour3d()
Was this page helpful?
0 / 5 - 0 ratings

Related issues

thoth291 picture thoth291  ·  10Comments

rahulporuri picture rahulporuri  ·  3Comments

Kekushke picture Kekushke  ·  9Comments

GaelVaroquaux picture GaelVaroquaux  ·  13Comments

stefanoborini picture stefanoborini  ·  11Comments