*  Informatique / Python / Build Python 3.6.0 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/3.6.0/Python-3.6.0.tar.xz 
  tar -Jxf Python-3.6.0.tar.xz 
  cd Python-3.6.0 
  ./configure --enable-shared --enable-optimizations  --with-ensurepip=install --prefix=/fcopt/python3.6.0 
  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/python3.6.0/bin:/usr/bin:/bin 
export PYTHONPATH=/fcopt/python3.6.0/lib/python3.6/site-packages 
export LD_LIBRARY_PATH=/fcopt/python3.6.0/lib

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

pip3 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.0.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.0/VTK-7.0.0.tar.gz 
tar zxvf VTK-7.0.0.tar.gz 
mkdir VTK-7.0.0-py3.6.0 
cd VTK-7.0.0-py3.6.0 
ccmake -DCMAKE_INSTALL_PREFIX:PATH=/fcopt/VTK/vtk7.0-py3.6.0 \ 
     -DBUILD_SHARED_LIBS:BOOL=ON \ 
     -DVTK_WRAP_PYTHON:BOOL=ON \ 
     -DVTK_PYTHON_VERSION:STRING=3 \ 
     -DPYTHON_EXECUTABLE:PATH=/fcopt/python3.6.0/bin/python3 \ 
     -DPYTHON_INCLUDE_DIR:PATH=/fcopt/python3.6.0/include/python3.6m \ 
     -DPYTHON_LIBRARY:PATH=/fcopt/python3.6.0/lib/libpython3.6m.so \ 
     ../VTK-7.0.0

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

make install

To 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.0-py3.6.0/lib/python3.6/site-packages 
export LD_LIBRARY_PATH=/fcopt/VTK/vtk7.0-py3.6.0/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/python3.6.0/bin/python3 configure.py 
make 
make instal

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/python3.6.0/bin/python3 configure-ng.py 
make 
sudo make install

I need to do make install as root!!!

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.

pip3 install numpy scipy matplotlib

*  Installing mayavi

pip3 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/python3.6.0/bin:/usr/bin:/bin 
export PYTHONPATH=/fcopt/python3.6.0/lib/python3.6/site-packages:/fcopt/VTK/vtk7.0-py3.6.0/lib/python3.6/site-packages 
export LD_LIBRARY_PATH=/fcopt/python3.6.0/lib:/fcopt/VTK/vtk7.0-py3.6.0/lib 
export MPLBACKEND=Qt4Agg

The MPLBACKEND environment variable is used to set matplotlib backend.

*  Troubles