How to Install VTK (with Python Wrapper) on Red Hat Enterprise Linux (RHEL)

7,222

Solution 1

Installing VTK Dependencies

Ensure gcc and g++ are installed:

yum install gcc
yum install gcc-c++

Ensure cmake is installed:

yum install cmake

Ensure OpenGL modules are installed

yum install mesa-libGL
yum install mesa-libGL-devel

(mesa-libGL is an MIT licensed implementation of OpenGL which RHEL uses)

Ensure X11_Xt_LIB is installed:

yum install libXt-devel

Ensure Python Libraries are installed:

yum install python-devel

Ensure NumPy is installed

yum whatprovides numpy  # this will provide a list of package names  
sudo yum install <package name>

example : sudo yum install numpy-1.7.1-11.el7.x86_64

Ensure TCL is installed

sudo yum install tcl

Installing VTK (with Python Wrapper)

Here is the reference that was used for this step

  1. Install latest tarball source code from http://www.vtk.org/download/, e.g. VTK-7.0.0.tar.gz

  2. Create the following VTK file structure:

    mkdir $HOME/VTK
    
  3. extract the tarball contents into the $HOME/VTK folder:

    tar -xvf ~/Downloads/VTK-X.X.X.tar.gz -C ~/VTK
    
    • replace X.X.X with your version number
    • make sure ~/Downloads/ contains your tarball
  4. move the contents of VTK-X.X.X folder directly into $HOME/VTK/ and remove the folder VTK-X.X.X

  5. Modify your .bashrc file

    • Open .bashrc:

      sudo nano ~/.bashrc
      
    • Add export VTK_ROOT=$HOME/VTK/ to the file
    • run the command source $HOME/.bashrc
  6. Build VTK with CMake

    • cd $VTK_ROOT
      mkdir build
      cd build
      cmake ../ -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release -DVTK_WRAP_PYTHON=ON
      

      Note: if this command says there is no CMakeLists.txt, then the path '../' does not lead to the folder with the extracted data. Make sure you completed the movement of the files specified in step 4.

    • make -j5
      

      This will take a while the first time

    • make test
      

      Tests to make sure everything installed properly, this too takes a while

      • The result should be similar to 99% tests passed, 7 tests failed out of 1448. The fewer failures the better, however.
      • If many of them are failing, it may be because the build folder is not surrounded by the source folders, e.g. Accelerators, Charts, etc...

Python Wrapper

Modify your .bashrc file

  • sudo nano ~/.bashrc
    
  • Add the following lines to the file

    export PYTHONPATH=$VTK_ROOT/build/Wrapping/Python/:$VTK_ROOT/build/bin:$VTK_ROOT/build/lib
    export LD_LIBRARY_PATH=$VTK_ROOT/build/bin:$VTK_ROOT/build/lib:$LD_LIBRARY_PATH
    

Test installation to make sure it worked

  • python
    import vtk
    

    Assuming the import vtk command did not complain to you, you're all set.

Solution 2

A better alternative to building it from source is to install a repository that includes it. EPEL actually has it.

Download the latest epel-release*.rpm from http://dl.fedoraproject.org/pub/epel/6/x86_64/

Install epel-release rpm:

rpm -Uvh epel-release*.rpm

Install the VTK package:

yum install vtk
Share:
7,222

Related videos on Youtube

Ulad Kasach
Author by

Ulad Kasach

Updated on September 18, 2022

Comments

  • Ulad Kasach
    Ulad Kasach over 1 year

    A program I need to compile is dependent on VTK v5.4+ with Python Wrapper. VTK is not in the standard YUM repo's.

    How can I install this dependency?

    I am running RHEL 7 under developer subscription.

  • Julie Pelletier
    Julie Pelletier over 7 years
    The main problem with building packages from source is that they are not managed by your system's package manager and eventually may cause conflicts.
  • Honghe.Wu
    Honghe.Wu over 7 years
    after install, run: sudo ldconfig to update ld_library, instead of export LD_LIBRARY_PATH