Informatique / Python / Build Python 3.6.0 with Mayavi 4.5.0 on ubuntu 14.04 LTS
There is no ubuntu 14.04 LTS packages for this version, so we must install it using sources.
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
- The command make -j 4 failed with a core dump on my laptop so I only use make command.
- The option –enable-shared is needed when building VTK python wrapper.
- The option –with-ensurepip=install permits the installation of setuptools and pip packages.
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:/binexport PYTHONPATH=/fcopt/python3.6.0/lib/python3.6/site-packages
To test the installation, I use pip3 to install ipython package :
The mayavi package requires VTK (with ccmake command) and PyQt package to be installed.
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.
Then in the ccmake windows, I press configure key [c] twice and then press key [g] to generate
wget http://www.vtk.org/files/release/7.0/VTK-7.0.0.tar.gztar zxvf VTK-7.0.0.tar.gz
mkdir VTK-7.0.0-py3.6.0cd VTK-7.0.0-py3.6.0ccmake -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_LIBRARY:PATH=/fcopt/python3.6.0/lib/libpython3.6m.so \ ../VTK-7.0.0
To test the VTK python wrapper, one have to add paths to the previously initialized environment variables
PYTHONPATH and LD_LIBRARY_PATH :
and run the python code sphere.py (700 bytes) .
We first have to install sip package. The environment variables PATH, PYTHONPATH and LD_LIBRARY_PATH must
be correctly set.
tar zxvf sip-4.19.1.tar.gzcd sip-4.19.1/fcopt/python3.6.0/bin/python3 configure.pymakemake instal
Then we can install PyQt4 package (PyQt5 failed ?)
I need to do make install as root ! ! !
tar zxf PyQt4_gpl_x11-4.12.tar.gzcd PyQt4_gpl_x11-4.12/fcopt/python3.6.0/bin/python3 configure-ng.py
makesudo make install
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
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
The MPLBACKEND environment variable is used to set matplotlib backend.
export LD_LIBRARY_PATH=/fcopt/python3.6.0/lib:/fcopt/VTK/vtk7.0-py3.6.0/libexport MPLBACKEND=Qt4Agg
- When saving a mlab figure in pdf format , I have the following error :
Saving as a vector PS/EPS/PDF/TeX file using GL2PS is either not supported
by your version of VTK or you have not configured VTK to work with GL2PS
-- read the documentation for the vtkGL2PSExporter class.