Bash: vtk command not found

Dear all,
I have installed VTK from source using CMake, and I couldn’t run
vtk mace.tcl

I see the tutorial here:
(The Visualization Toolkit)

it said “vtk command not found”

I have adjusted the environment variables, and moved all the compiled
files to my destination folder for VTK.
I am using my own OS made with Linux From Scratch. I run it on Qemu/KVM.
I can run vtk from inside python interpreter. I can do “import vtk”, but on the console terminal I cannot run the .tcl file. I can run VTK with Python following this tutorial:
(Project 0: Getting VTK... to Work).

I just want to run vtk from bash without using Python interpreter.

Thank You

VTK does not wrap for TCL anymore.

If you want to execute a VTK python script you can use vtkpython.


Alright so I cannot open .tcl file anymore. Thanks

That book hasn’t been updated, it uses VTK 4.2, we are now up to VTK 9.1 so Python or C++ is the way to go.

Also have a look here for Python and C++ examples: vtk-examples. The examples will compile/run with the VTK master. Also there is a PDF of the VTK TextBook and most of the examples in it will run with VTK 9+.

Yes thanks for the answer, but I just figure out recently following the vtk-examples link.
I cannot run cmake on this vtk-example

It said that:

There are missing files:
add the installation prefix of “VTK” to CMAKE_PREFIX_PATH
set VTK_DIR to the above files

You need to check out and download the source files, see ForDevelopers, then you need to make sure CMake knows where the VTK build is.

Hi Andrew, thanks for the reply
I am following this link:

I do:
git clone --recursive
then inside the vtk folder I
mkdir build
cd build
then I run:
Now after ccmake generate files inside the build folder I run:

I am waiting now since it is compiling as I send this post.
When it is done I will do:
make install

I set the CMAKE_INSTALL_PREFIX to /opt/hamzstlib

Previously, I have downloaded VTK-9.1.0.tar.gz from this:

But when I do ninja install / make install the installation folder does not have lib folder or VTKconfig.cmake file so VTK can be found in my system.

How to make sure CMake knows where the VTK build is? To make VTK works?


If you are trying to build the Python wheel, then follow the instructions in:

Note that you need the path to the VTK source, in your case /opt/hamzstlib/VTK-9.1.0.

From what I can see,

/opt/hamzstlib/Vtk9/build is where your build is. This will contain vtk-config.cmake, so in your environment you need:


The problem is I have search through the folders and files inside the build folder /opt/hamzstlib/Vtk9/build.

There is no vtk-config.cmake

I need to know whether my CMake scripts are wrong, I am trying to rebuild it again now.

What are the last few lines of output of each of the commands? If it’s taking the build command is taking a long time, the cmake command was probably successful. What are the last few lines of output of your make/ninja command for building and the last few lines of output of your make/ninja install command?

This is the scripts to build VTK:

cmake -GNinja \
  -S ./VTK-9.1.0 \
  -B ./vtk-build \
  -D CMAKE_INSTALL_PREFIX=/opt/hamzstlib/vtk91 \
  -D VTK_WHEEL_BUILD=ON /opt/hamzstlib/VTK-9.1.0 

then after that a vtk-build folder is created and then I run:

 cmake --build ./vtk-build
 cmake --install ./vtk-build --prefix ./vtk-install

What is the correct one? what is your installation, and build scripts? Maybe it can help me.

–prefix ./vtk-install

This option is overriding your CMAKE_INSTALL_PREFIX directive of your cmake command, so if your last command is working, your vtk files are installed in ./vtk-install.

What is in that directory? What are the last few lines of output when you run that command?

@Freya_the_Goddess , my feeling is that you should start with a build in your home folder and once this works, then:

  • Familarise yourself with the directory structure and what needs to be set in the environment in order to build C++ code and Python code.
  • Adjust the VTK build parameters specifying what you want in cmake.
  • When you are satisfied, then consider building and installing a wheel, if you want.

To help you do this I have just written and tested some instructions that will lead you step by step through the process of setting up VTK in your home folder. The instructions cover:

  • what is needed to build VTK
  • setting up a virtual environment for VTK
  • building VTK
  • running some test cases for C++ and Python.

They use the latest release of VTK.

I hope the instructions are useful. (4.2 KB)

Thanks for the reply…

Yes it is installed in ./vtk-install

The command is overriding the CMAKE_INSTALL_PREFIX but it is still installed anyway.
The last lines I use till vtk-install is made are:

 cmake --build ./vtk-build
 cmake --install ./vtk-build --prefix ./vtk-install

Some say that it is not right since the vtk-install should contain these directories:
bin/ include/ lib/ share/

that will include the VTKConfig.make and vtk-config.make as well so I can point my VTK_DIR correctly.
What do you think ?

Thanks for the reply Andrew,

I am looking at your and will try it today.
I was suggested to create a build log to figure out my my installation folder is not the way is suppose to be. Here is my build log if you want to see it and have time:

I am using ninja -j4.

It looks like everything built. I strongly suggest that you try my instructions and do a build in your home directory. This will give you a good basis for:

  • folder structures in the VTK build folder
  • what you need to do to build your own code and how to set up Python
  • once you check that there are no errors and the tests work, you can modofy with confidence


Thanks for everything Andrew Maclean your instruction should be spread widely.

A question:

What is wheel? I am new to Python too and just learning very basic now.
Is it like package or module in Python?

A wheel is a Python package that you can install. Basically since you are not well verse with building VTK, you should either use a pre-built wheel version (pip install vtk) or build VTK with the basic options.

So far you are using conflicting build options.

In your command

cmake -GNinja \
  -S ./VTK-9.1.0 \
  -B ./vtk-build \
  -D CMAKE_INSTALL_PREFIX=/opt/hamzstlib/vtk91 \
  -D VTK_WHEEL_BUILD=ON /opt/hamzstlib/VTK-9.1.0 
  1. You are providing the source directory twice
    -S ./VTK-9.1.0 and /opt/hamzstlib/VTK-9.1.0 . I don’t think it matters but still, there is no point to setting the same key to maybe two different values.
  2. Why are you enabling Java? -D VTK_WRAP_JAVA=ON Are you planning to use Java? Java tend to require a different install tree than standard C++ library so the JVM can load those libraries easily.
  3. -D VTK_USE_TK=ON Why?
  4. -D VTK_WHEEL_BUILD=ON Are you aiming to publish your VTK build to PyPI? This also imply some tree structure that might be incompatible with Java and maybe even VTK install tree for C++.

To summarize, if you don’t know what those options are for, don’t enable them. I already gave you the properties required to build VTK with Python support along with how to build an example against your build and install tree.

Yes I made VTK works with the basic options. Now try some examples from the website.

To asnwer your questions

  1. I didn’t know that, thanks for mentioning. I learn a lot from mistakes here
  2. I didn’t know that Java will require different install tree, maybe that is why all the previous builds was not working
  3. TK is for Tkinter right? I think if I want to use C++ and Python, I need TK too. Sorry if I am wrong on this.
  4. So the Wheel is only to publish VTK build to PyPI not to enhance Python features in VTK?

Thank You Sebastien