By itself Mayavi is not a difficult package to install but its dependencies are unfortunately rather heavy. Fortunately, many of these dependencies are now available as wheels on PyPI. The two critical dependencies are,
The latest VTK wheels are available on all the major platforms (Windows, MacOS, and Linux), but only for 64 bit machines. Python 3.x is fully supported on all these operating systems and Python 2.7.x on MacOS and Linux. If you are out of luck, and your platform is not supported then you will need to install VTK yourself using your particular distribution as discussed in the General Build and Installation instructions
On Python 3.x you will need to install PyQt5 and wheels are available for this. On 2.7.x you have more options, and can use PySide, PyQt4, and wxPython. These can be installed from pip or from your package manager.
Currently, Mayavi itself should work with the new wxPython 4.x. However, traitsui, pyface, and other ETS packages do not yet support it so the UI will not work correctly. Older versions should work. PyQt/PySide should work largely out of the box. PySide2 is still young so YMMV.
Installing with pip¶
Required python packages can be automatically fetched and installed with pip.
Latest stable release¶
As of the latest release, i.e. 4.6.0 and above, if you are using Python 3.x and are on a 64 bit machine, installation via pip is the easiest and is as follows:
$ pip install mayavi $ pip install PyQt5
If you are unable to do this, read the documentation above and find a way to install VTK and a suitable UI toolkit and then repeat the above.
If you are interested in the jupyter notebook support as well, do the following (after ensuring that you have jupyter installed of course):
$ jupyter nbextension install --py mayavi --user $ jupyter nbextension enable --py mayavi --user
If you want to install the latest version of Mayavi from github, you can simply do the following:
$ git clone https://github.com/enthought/mayavi.git $ cd mayavi $ pip install -r requirements.txt $ pip install PyQt5 # replace this with any supported toolkit $ python setup.py install # or develop
Add the jupyter nbextensions using the instructions in the section above and you should be good to go.
Mayavi depends on several packages that are part of ETS. Sometimes it is possible that the in-development mayavi version may depend on some feature of an unreleased component. The ETS packages that Mayavi depends on are apptools, traits_, traitsui, pyface, and envisage_. In case one of these are required these can also be installed via git. They are all relatively easy to install packages.
Installing ready-made distributions¶
Under Windows the best way to install Mayavi is to install a full Python distribution, such as Enthought Canopy, Pythonxy, or Anaconda. Note that for Pythonxy, you need to check in ‘ETS’ in the installer, when selecting components. If you want to reduce the disk space used by Pythonxy, you can uncheck other components.
- Ubuntu or Debian:
- RedHat EL3 and EL4:
The full Python distribution Enthought Canopy (that includes Mayavi) is also available for RHEL3 and 4.
EDM is Enthought’s freely available python environment manager. It allows new python users to create light-weight and custom python environments. A major advantage of EDM is its robust state-of-the-art management of package dependencies, with support for resolving conflicts and ensuring consistent package version sets. It can be downloaded from edmInstaller.
EDM provides Python 2.7.x as well as Python 3.x runtimes. Python 2.7 is the default version. After installing EDM, mayavi can be easily installed from the terminal by using edm:
$ edm install mayavi pyqt
This will install mayavi along with ‘pyqt’. After this, you can start a shell with the default python version by running:
$ edm shell
This should set Mayavi for the default python 2.7.
For python 3.6.x, you can install it by running:
$ edm environments create –version 3.6 py3
Where ‘py3’ is the name of the environment. You may change this name to something else if you wish. Once you create the environment, you can activate it as follows:
$ edm shell -e py3
You can now install mayavi as follows:
$ edm install mayavi pyqt
Note that ‘pyqt’ needs to be installed explicitly for python 3.6 as well as for python 2.7.
Conda is an open source package management environment management system for installing multiple versions of software packages and their dependencies. Conda is included in Anaconda and Miniconda.
Miniconda is a small “bootstrap” version that includes conda, python, and the packages they depend on. Depending on your operating system, you can download the MinicondaInstaller
After installing conda you need to run the following from command line:
$ conda create -n pyconda python=3.5 pyqt=4 $ source activate pyconda $ conda install -c menpo mayavi
You should be all set with this. As of Mayavi 4.6.0 you can also use
Installing with Conda-forge¶
Conda-forge is a community-led conda channel of installable packages. For more information on conda-forge, you can vist their their website.
Follow these steps to install using conda-forge:
First, clone the environment or build one from scratch:
$ conda create --name pyforge --clone root or $ conda create --name pyforge python=2.7
Then add the conda-forge channel:
$ conda config --add channels conda-forge
Activate the ‘pyforge’ environment:
$ source activate pyforge
You will need to install these dependencies for Mayavi:
$ conda install vtk $ conda install pyqt=4
Finally, Mayavi can be installed as:
$ conda install mayavi
Testing your installation¶
The easiest way to test if your installation is OK is to run the mayavi2 application like so:
To get more help on the command try this:
mayavi2 is the mayavi application. On some platforms like win32
you will need to double click on the
mayavi2.exe program found in
PythonXY\Scripts folder. Make sure this directory is in your
Mayavi can be used in a variety of other ways but the
application is the easiest to start with.
If you have the source tarball of mayavi or have checked out the sources
from the github repository, you can run the examples in
mayavi*/examples. There are plenty of example scripts
illustrating various features. Tests are available in the
The basic test suites for tvtk and mayavi can be run using nose:
nosetests -v tvtk/tests nosetests -v mayavi
The integration tests can be run as:
cd integrationtests/mayavi python run.py
If you are having trouble with the installation you may want to check the Getting help page for more details on how you can search for information or email the mailing list.