Mayavi: Mayavi installation issue in Mac OSX through Homebrew and pip

Created on 21 Dec 2016  ·  9Comments  ·  Source: enthought/mayavi

I'm trying to install and use mayavi in Mac OSX through homebrew and pip. I have installed python2, qt5, pyqt5 and vtk 7.1 through homebrew and changed path to make Homebrew python the default one. Then, when I try to install mayavi through pip. When i run mayavi2 in command line, I get the following error. I dont see a TraitsBackendWx or TraitsBackendQt in pip search. How to resolve this error?

Traceback (most recent call last):
  File "/usr/local/bin/mayavi2", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/mayavi/scripts/mayavi2.py", line 647, 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
<pkg_name>. easy_install Mayavi[app] will also work.

If you performed a source checkout, be sure to run 'python setup.py install'
in Traits, TraitsGUI, and the Traits backend of your choice.

Also make sure that either wxPython or PyQT is installed.
wxPython: http://www.wxpython.org/
PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro

Most helpful comment

Indeed the Qt5 backend does work perfectly! (well, with all the examples I tested ;) using both the mayavi program as well as ipython) Thanks for your hint!
When I was browsing the source code I found code for a Qt5 backend already committed months ago, so I somehow assumed this was released already, not noticing that the corresponding pip packages/releases are already ~1.5 years old.

To be more precise about my setup: I'm running OSX and have python 3.6, Qt5, VTK and PyQt installed using the package manager homebrew. I installed/built traitsui, pyface and mayavi at current git master using pip3. All the other dependencies were installed from pip3 in their regular release form.

So, as for this ticket, I guess it can be closed with the following verdict regarding backends on OSX:

  • wxPython is only an option when you are using python 2.x
  • When using python 2.x you might also be able to use PyQT4/PySide (but you have to build it either yourself or use other package managers than homebrew/pip)
  • When using python 3.x you should use PyQT5 but need to build traitsui/pyface/mayavi from git master
  • PySide (Qt4) is only an option for a limited range of python 3.x versions (with x < 5, IIRC), PySide 2 (Qt5) is not supported as far as I'm aware? But I didn't test these, just wanted to mention them

All 9 comments

Hi @rambalachandran, TraitsBackendWx and TraitsBackendQt are superseded by traitsui and pyface. Could you try to install traitsui and pyface please? And you might want to use qt4 and pyqt4 instead of Qt5.

Thank you. Can you please tell me how to install pyqt4? When I try pip install PyQt4 it throws me an error, although pip search PyQt4 shows that such a package exists

I installed all the relevant packages. I could not find PyQt4 or wxPython in pip, so I installed PySide. I have included the pip freeze as an attachment here. Even after that, when I try to run mayavi2, I get the same error

Traceback (most recent call last):
  File "/usr/local/bin/mayavi2", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/mayavi/scripts/mayavi2.py", line 647, 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
<pkg_name>. easy_install Mayavi[app] will also work.

If you performed a source checkout, be sure to run 'python setup.py install'
in Traits, TraitsGUI, and the Traits backend of your choice.

Also make sure that either wxPython or PyQT is installed.
wxPython: http://www.wxpython.org/
PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro

pipInstallations.txt

Installing wxpython from homebrew solved the issue and the GUI for mayavi2 now opens.

@rambalachandran -- can we close this issue?

Does this mean I'm out of luck on OSX using python 3.6?
The mentioned package manager homebrew only has classic wxPython, which does not support python 3. pip actually abandoned this version and supplies the python 3 compatible "phoenix" version but mayavi is incompatible to this one.
pip3 does not have a PyQT4 distribution for OSX and PyQt5 is not supported (at least it is not picked up by traits, even though it imports successfully by hand)?
That's a quite uncomfortable situation.

@Argon- -- does this hold for the version from github or did you pip install it from pypi. The latest version should work with Qt5 but also requires more recent versions of traitsui/pyface which are not yet released. I'll ask about a new traitsui/pyface release supporting qt5 then I will also push a mayavi release.

I tried current master of pyface but was unaware that I also need a more recent traitsui (and mayavi). Are there any other dependencies I need to build locally?
In that case, I will try/test again (tomorrow) and report back.

Indeed the Qt5 backend does work perfectly! (well, with all the examples I tested ;) using both the mayavi program as well as ipython) Thanks for your hint!
When I was browsing the source code I found code for a Qt5 backend already committed months ago, so I somehow assumed this was released already, not noticing that the corresponding pip packages/releases are already ~1.5 years old.

To be more precise about my setup: I'm running OSX and have python 3.6, Qt5, VTK and PyQt installed using the package manager homebrew. I installed/built traitsui, pyface and mayavi at current git master using pip3. All the other dependencies were installed from pip3 in their regular release form.

So, as for this ticket, I guess it can be closed with the following verdict regarding backends on OSX:

  • wxPython is only an option when you are using python 2.x
  • When using python 2.x you might also be able to use PyQT4/PySide (but you have to build it either yourself or use other package managers than homebrew/pip)
  • When using python 3.x you should use PyQT5 but need to build traitsui/pyface/mayavi from git master
  • PySide (Qt4) is only an option for a limited range of python 3.x versions (with x < 5, IIRC), PySide 2 (Qt5) is not supported as far as I'm aware? But I didn't test these, just wanted to mention them
Was this page helpful?
0 / 5 - 0 ratings