using vtk 8.2.0 with python wrappings with anaconda


i built vtk with python wrappings successfully, when i go to bin in the build folder and run the vtkpython executable, it works properly with anaconda python version that i have given.

when i open a new terminal window and try run python and try to import vtk, i get no module found error.

if i try to install it in the anaconda/lib/python3.6/site-packages and then run i get
Fatal Python error: PyThreadState_Get: no current thread error.

how do i connect built vtk to anaconda python?


You’ll have to rebuild VTK and

at configure time, make sure the python executable and python headers point to conda versions rather than system versions.

So look in your CMakeCache.txt for all python variables and make sure the point correctly.

Hope it helps,


Hi Dan,

i used cmake GUI, i did set all the python variables to anaconda version, the lib, include and exec paths,
after build, it is created a python folder in lib in the build folder with path build/lib/python3.6/site-packages/ with vtk inside it. and the bin folder in build path has vtkpython exec.

(i used release build)

when i copied contents of build/lib/python3.6/site-packages/ to anaconda/lib/python3.6/site-packages/ it is throwing the Fatal Python error: PyThreadState_Get: no current thread error.

You may need to build VTK master to fix this problem and you’ll have to patch VTK master like this:

diff --git a/Utilities/Python/CMakeLists.txt b/Utilities/Python/CMakeLists.txt
index 632069bc0d..44e4371b1a 100644
--- a/Utilities/Python/CMakeLists.txt
+++ b/Utilities/Python/CMakeLists.txt
@@ -147,7 +147,7 @@ cmake_dependent_option(VTK_PYTHON_OPTIONAL_LINK
   # `target_link_options`.
   # XXX(Linux): Currently, this causes missing symbols on Linux in ParaView.
   # More investigation is necessary.
-  "FALSE;BUILD_SHARED_LIBS;COMMAND target_link_options" OFF)
+  "BUILD_SHARED_LIBS;COMMAND target_link_options" OFF)
 add_library(PythonUsed INTERFACE)
 add_library(VTK::PythonUsed ALIAS PythonUsed)

See the following thread for context:

Also, you’ll need cmake >= 3.13 for this to work

The patch won’t be needed after this MR goes in.

Hi Dan, i tested this solution and it worked

thanks for your help in resolving this solution