In this section we explain how to install Mayavi Python package (from PyPI) for several versions of Python on some
Linux distributions.
The steps are the following:
installing some required packages (as root) to be able to compile Python sources,
downloading Python sources,
compiling and installing Python,
installing PyQt version 5 Python package (or PySide2 Python package) to be used with Mayavi,
installing Mayavi Python package.
The installation process described here was succesfully tested on:
Linux | Python |
CentOS 7.5 | PyQt5: 3.5.6, 3.6.7 |
PySide2: 2.7.15 | |
Debian 9.5 | PyQt5: 3.5.6, 3.6.7 |
PySide2: 2.7.15 | |
Fedora 29 | PyQt5: 3.5.6, 3.6.7 |
PySide2: 2.7.15 | |
openSUSE 29 | PyQt5: 3.5.6, 3.6.7 |
PySide2: 2.7.15 | |
Ubuntu 18.04 | PyQt5: 3.5.6, 3.6.7 |
PySide2: 2.7.15 | |
Before we can compile Python sources, we install (as root) some system packages. Other packages than those suggested below may be necessary depending on the configuration of your system.
We 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.7 version. To use another version,
one only has to set PYVER variable. The PYDIR variable contains /fcopt/PYTHON/3.6.7 which is the
installation directory and the CDIR variable contains ~/compil which is the compilation directory.
PYVER=3.6.7 CDIR=~/compil DIR=/fcopt PYDIR=$DIR/PYTHON/$PYVER mkdir -p $CDIR cd $CDIR # downloading wget https://www.python.org/ftp/python/$PYVER/Python-$PYVER.tar.xz # extracting 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)
On CentOS 7.5 with version 3.7.0 of Python, I need to only use one thread ( python missing builtin ’runpy’ message...)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. For example:
... 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. ...
Thereafter one can update PIP:
orTo correctly use and test this installed Python version, we update some environment variables:
PYVER=3.6.7 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/pyqt5_window.py $PYDIR/bin/python${PYVER%%.*} pyqt5_window.py
I install this package when PyQt5 Python package is not available on PyPI.
On november 2018, the version 5.11.2 is installed. One can run the python code pyside2_t10.py (6492 bytes) :wget http://www.math.univ-paris13.fr/~cuvelier/docs/Informatique/Python/pyside2_t10.py $PYDIR/bin/python${PYVER%%.*} pyside2_t10.py
We set some environment variables. If PyQt5 Python package is installed:
Otherwise, if PySide2 Python package is installed:To install the mayavi package one can do:
To quickly test the mayavi package, one can run the python code mayavi_boy.py (774 bytes) .
wget http://www.math.univ-paris13.fr/~cuvelier/docs/Informatique/Python/mayavi_boy.py $PYDIR/bin/python${PYVER%%.*} mayavi_boy.py