*  Informatique / Python / Building Python 2.7.13 with Mayavi 4.5.0 on ubuntu 14.04 LTS

        * Installing VTK
        * Installing PyQt
        * Installing matplotlib, numpy, ...
        * Installing mayavi
        * Troubles

There is no ubuntu 14.04 LTS packages for this version, so we must install it using sources.

pict pict

I assume the installation directory /fcopt I choose is writeable (for me), otherwise one have to install as root.

wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
tar -Jxf Python-2.7.13.tar.xz
cd Python-2.7.13
./configure --enable-shared --enable-optimizations  --with-ensurepip=install --prefix=/fcopt/python2.7.13
make
make install

Installed versions are pip-9.0.1 and setuptools-28.8.0.

To correctly use and test this installed python version

export PATH=/fcopt/python2.7.13/bin:/usr/bin:/bin
export PYTHONPATH=/fcopt/python2.7.13/lib/python2.7/site-packages
export LD_LIBRARY_PATH=/fcopt/python2.7.13/lib

To test the installation, I use pip to install ipython package :

pip install ipython

The mayavi package requires VTK (with ccmake command) and PyQt package to be installed.

*  Installing VTK

I have some troubles when compiling version 6.3.0 of VTK, so I install version 7.1.0. I choose as installation directory /fcopt/VTK/vtk7.0-py3.6.0 which is writeable for me.

wget http://www.vtk.org/files/release/7.1/VTK-7.1.0.tar.gz
tar zxvf VTK-7.1.0.tar.gz
mkdir VTK-7.1.0-python2.7.13
cd VTK-7.1.0-python2.7.13
ccmake -DCMAKE_INSTALL_PREFIX:PATH=/fcopt/VTK/vtk7.1.0-py2.7.13 \
       -DBUILD_SHARED_LIBS:BOOL=ON \
       -DVTK_WRAP_PYTHON:BOOL=ON \
       -DVTK_PYTHON_VERSION:STRING=2 \
       -DPYTHON_EXECUTABLE:PATH=/fcopt/python2.7.13/bin/python \
       -DPYTHON_INCLUDE_DIR:PATH=/fcopt/python2.7.13/include/python2.7 \
       -DPYTHON_LIBRARY:PATH=/fcopt/python2.7.13/lib/libpython2.7.so \
       ../VTK-7.1.0

Then in the ccmake windows, I press configure key [c] twice and then press key [g] to generate ...

make install

After 35mn on my laptops, I can test the VTK python wrapper : one have to add paths to the previously initialized environment variables PYTHONPATH and LD_LIBRARY_PATH :

export PYTHONPATH=$PYTHONPATH:/fcopt/VTK/vtk7.1.0-py2.7.13/lib/python2.7/site-packages
export LD_LIBRARY_PATH=/fcopt/VTK/vtk7.1.0-py2.7.13/lib:$LD_LIBRARY_PATH

and run the python code sphere.py (700 bytes) .

*  Installing PyQt

We first have to install sip package. The environment variables PATH, PYTHONPATH and LD_LIBRARY_PATH must be correctly set.

wget https://sourceforge.net/projects/pyqt/files/sip/sip-4.19.1/sip-4.19.1.tar.gz
tar zxvf sip-4.19.1.tar.gz
cd sip-4.19.1
/fcopt/python2.7.13/bin/python configure.py
make
make install

Then we can install PyQt4 package (PyQt5 failed ?)

wget https://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.12/PyQt4_gpl_x11-4.12.tar.gz
tar zxf PyQt4_gpl_x11-4.12.tar.gz
cd PyQt4_gpl_x11-4.12
/fcopt/python2.7.13/bin/python configure-ng.py
make
sudo make install

The make command take about 10mn. I need to do make install as root : the Designer plugin will be installed in
/usr/lib/x86_64-linux-gnu/qt4/plugins/designer

To quickly test the PyQt4 package, one can run the python code pyqt4_window.py (339 bytes) .

*  Installing matplotlib, numpy, ...

I choose to install matplotlib package after the installation of PyQt.

pip install numpy scipy matplotlib

*  Installing mayavi

pip install mayavi

The mayavi-4.5.0 python package is now installed.

To quickly test the mayavi package, one can run the python code mayavi_boy.py (774 bytes) .

With this installation, I set the environment variables PATH, PYTHONPATH and LD_LIBRARY_PATH before to use python3, ipython3, ... as follows

export PATH=/fcopt/python2.7.13/bin:/usr/bin:/bin
export PYTHONPATH=/fcopt/python2.7.13/lib/python2.7/site-packages:/fcopt/VTK/vtk7.1.0-py2.7.13/lib/python2.7/site-packages
export LD_LIBRARY_PATH=/fcopt/python2.7.13/lib:/fcopt/VTK/vtk7.1.0-py2.7.13/lib
export MPLBACKEND=Qt4Agg

The MPLBACKEND environment variable is used to set matplotlib backend.

*  Troubles