In this section I explain how to install Mayavi 4.5.1 (development version) on Python 2.7.x, 3.5.x or 3.6.x on
CentOS 7.
The steps are the following:
installing some required packages
compiling and installing Python
installing VTK Python wrapper
installing PyQt version 5 Python package (version 5 not supported by Mayavi 4.5.0)
installing Mayavi 4.5.0 Python package
upgrading Mayavi Python package to version 4.5.1 (Enthought development version)
upgrading pyface and traitsui Python package to version >=5.2.0 (Enthought development version)
The installation process described here was succesfully tested with Python 2.7.14, 3.5.5 and 3.6.4.
To use Mayavi 4.5.0 python package, the version 4 of PyQt is needed: version 5 is not supported in this version of Mayavi. To use PyQt version 5 one has to install Mayavi 4.5.1 (development version on march 2018), pyface (>= 5.2.0) and traitsui (>=5.2.0)
On my CentOS 7 computer, I need to install (as root) the following system packages to compile Python
sudo yum install gcc gcc-c++ gcc-gfortran ncurses-devel tk-devel gdbm-devel \ readline-devel sqlite-devel bzip2-devel openssl-devel xz-devel
I assume the installation directory to be /fcopt. This directory is writable for me, otherwise one has to be root for
install process. The directory ~/compil is used as working directory.
The following compilation/installation commands are given for Python 3.6.4 version. To use another version,
one only has to set PYVER variable. The PYDIR variable contains /fcopt/PYTHON/3.6.4 which is the
installation directory and the CDIR variable contains ~/compil which is the compilation directory.
PYVER=3.6.4 CDIR=~/compil DIR=/fcopt PYDIR=$DIR/PYTHON/$PYVER mkdir -p $CDIR cd $CDIR wget https://www.python.org/ftp/python/$PYVER/Python-$PYVER.tar.xz tar -Jxf Python-$PYVER.tar.xz cd Python-$PYVER ./configure --enable-shared --enable-optimizations --with-ensurepip=install --prefix=$PYDIR
The option –enable-shared is needed when building VTK python wrapper.
The option –enable-optimizations ensure to have an optimized version of Python. This option is time consuming as it requires running a lot of tests (approximatively 30 minutes on my computer). To quickly try Python compilation process, do not use this option!
The option –with-ensurepip=install permits the installation of setuptools and pip packages.
Thereafter the make command is used by using 8 threads (ususally use as maximum the number of core of your computer)
it is important to ensure that there are no important missing modules by reading last lines (before tests starting with –enable-optimizations option) of the output of previous make command. There is what I obtain on my computer:
... Python build finished, but the necessary bits to build these modules were not found: _bsddb bsddb185 dl imageop sunaudiodev To find the necessary bits, look in setup.py in detect_modules() for the module’s name. ...
missing modules | packages |
_tkinter | tk-devel |
_gdbm and _dbm | gdbm-devel |
_sqlite3 | sqlite-devel |
_lzma | xz-devel |
If some CentOS packages are installed to prevent missing modules one has to rerun the configure command the make
command.
At last one can install Python under $PYDIR directory
export PATH=$PYDIR/bin:/usr/bin:/bin export PYTHONPATH=$PYDIR/lib/python${PYVER%.*}/site-packages export LD_LIBRARY_PATH=$PYDIR/lib
wget http://www.math.univ-paris13.fr/~cuvelier/docs/Informatique/Python/sphere.py $PYDIR/bin/python${PYVER%%.*} sphere.py
wget http://www.math.univ-paris13.fr/~cuvelier/docs/Informatique/Python/pyqt5_window.py $PYDIR/bin/python${PYVER%%.*} pyqt5_window.py
I choose to install matplotlib package after the installation of PyQt.
$PYDIR/bin/pip${PYVER%%.*} install git+https://github.com/enthought/mayavi.git $PYDIR/bin/pip${PYVER%%.*} install git+https://github.com/enthought/pyface.git $PYDIR/bin/pip${PYVER%%.*} install git+https://github.com/enthought/traitsui.git
wget http://www.math.univ-paris13.fr/~cuvelier/docs/Informatique/Python/mayavi_boy.py $PYDIR/bin/python${PYVER%%.*} mayavi_boy.py