# using vtk 8.2.0 with python wrappings with anaconda

**URL:** https://discourse.vtk.org/t/using-vtk-8-2-0-with-python-wrappings-with-anaconda/1060
**Category:** Support
**Created:** [May 31, 2019, 1:03pm UTC](https://discourse.vtk.org/t/using-vtk-8-2-0-with-python-wrappings-with-anaconda/1060 "2019-05-31T13:03:04Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![svabhishek29](https://discourse.vtk.org/user_avatar/discourse.vtk.org/svabhishek29/32/479_2.png) [@svabhishek29](https://discourse.vtk.org/u/svabhishek29)
#### Post date: [May 31, 2019, 1:03pm UTC](https://discourse.vtk.org/t/using-vtk-8-2-0-with-python-wrappings-with-anaconda/1060/1 "2019-05-31T13:03:05Z")

</div>

Hi,

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?

thanks

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [May 31, 2019, 1:12pm UTC](https://discourse.vtk.org/t/using-vtk-8-2-0-with-python-wrappings-with-anaconda/1060/2 "2019-05-31T13:12:22Z")

</div>

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,

Dan

---

<div class="post-metadata">

### Author: ![svabhishek29](https://discourse.vtk.org/user_avatar/discourse.vtk.org/svabhishek29/32/479_2.png) [@svabhishek29](https://discourse.vtk.org/u/svabhishek29)
#### Post date: [May 31, 2019, 1:38pm UTC](https://discourse.vtk.org/t/using-vtk-8-2-0-with-python-wrappings-with-anaconda/1060/3 "2019-05-31T13:38:04Z")

</div>

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.

 ![29%20PM](https://discourse.vtk.org/uploads/default/original/1X/cf503b4dc6cfd7d9819fbb8774d95469fcc51396.jpeg)  
(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.

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [May 31, 2019, 2:51pm UTC](https://discourse.vtk.org/t/using-vtk-8-2-0-with-python-wrappings-with-anaconda/1060/4 "2019-05-31T14:51:58Z")

</div>

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

```auto

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:

[https://discourse.vtk.org/t/segfault-for-python-importing-vtk-but-not-for-vtkpython/126](https://discourse.vtk.org/t/segfault-for-python-importing-vtk-but-not-for-vtkpython/126)

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [May 31, 2019, 4:02pm UTC](https://discourse.vtk.org/t/using-vtk-8-2-0-with-python-wrappings-with-anaconda/1060/5 "2019-05-31T16:02:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.vtk.org/user_avatar/discourse.vtk.org/danlipsa/32/390_2.png) [@danlipsa](https://discourse.vtk.org/u/danlipsa)
#### Post date: [May 31, 2019, 5:20pm UTC](https://discourse.vtk.org/t/using-vtk-8-2-0-with-python-wrappings-with-anaconda/1060/6 "2019-05-31T17:20:58Z")

</div>

The patch won’t be needed after this MR goes in.  
[https://gitlab.kitware.com/vtk/vtk/merge\_requests/5611](https://gitlab.kitware.com/vtk/vtk/merge_requests/5611)

---

<div class="post-metadata">

### Author: ![svabhishek29](https://discourse.vtk.org/user_avatar/discourse.vtk.org/svabhishek29/32/479_2.png) [@svabhishek29](https://discourse.vtk.org/u/svabhishek29)
#### Post date: [May 31, 2019, 7:07pm UTC](https://discourse.vtk.org/t/using-vtk-8-2-0-with-python-wrappings-with-anaconda/1060/7 "2019-05-31T19:07:43Z")

</div>

Hi Dan, i tested this solution and it worked

thanks for your help in resolving this solution
