# vtk build issue with QT and python wrapping

**URL:** https://discourse.vtk.org/t/vtk-build-issue-with-qt-and-python-wrapping/1053
**Category:** Support
**Created:** [May 30, 2019, 3:40pm UTC](https://discourse.vtk.org/t/vtk-build-issue-with-qt-and-python-wrapping/1053 "2019-05-30T15:40:14Z")
**Posts on this page:** 8
**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 30, 2019, 3:40pm UTC](https://discourse.vtk.org/t/vtk-build-issue-with-qt-and-python-wrapping/1053/1 "2019-05-30T15:40:14Z")

</div>

hi, i was trying to build vtk with QT and python wrappings turned on. The build completed successfully and even installation, but when i do import vtk in python i get error

> Traceback (most recent call last):  
> File “/anaconda3/lib/python3.6/site-packages/vtkmodules/vtkRenderingQt.py”, line 5, in   
> from .vtkRenderingQtPython import \*  
> ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/vtkmodules/vtkRenderingQtPython.so, 2): Library not loaded: @rpath/QtWidgets.framework/Versions/5/QtWidgets  
> Referenced from: /usr/local/lib/libvtkRenderingQt-8.2.1.dylib  
> Reason: Incompatible library version: libvtkRenderingQt-8.2.1.dylib requires version 5.12.0 or later, but QtWidgets provides version 5.11.0
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):  
> File “/Users/abhishek/Documents/python/spectre-v5/Spectre.py”, line 14, in   
> from controllers.ScanController import ScanController  
> File “/Users/abhishek/Documents/python/spectre-v5/controllers/ScanController.py”, line 6, in   
> import vtk  
> File “/anaconda3/lib/python3.6/site-packages/vtk.py”, line 32, in   
> all\_spec.loader.exec\_module(all\_m)  
> File “/anaconda3/lib/python3.6/site-packages/vtkmodules/all.py”, line 100, in   
> from .vtkRenderingQt import \*  
> File “/anaconda3/lib/python3.6/site-packages/vtkmodules/vtkRenderingQt.py”, line 9, in   
> from vtkRenderingQtPython import \*  
> ModuleNotFoundError: No module named ‘vtkRenderingQtPython’

how can i fix this problem?

Thanks

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 30, 2019, 3:47pm UTC](https://discourse.vtk.org/t/vtk-build-issue-with-qt-and-python-wrapping/1053/2 "2019-05-30T15:47:27Z")

</div>

You’ve built against a Qt 5.12, but at runtime, 5.11 is being found. The first error comes from the dynamic loader. The second is Python’s reaction to the loader saying “no”.

---

<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 30, 2019, 7:31pm UTC](https://discourse.vtk.org/t/vtk-build-issue-with-qt-and-python-wrapping/1053/3 "2019-05-30T19:31:19Z")

</div>

hi, i installed PyQt 5.12.2 and also built vtk with Qt 5.12.2, then i get this error when i try to run import vtk

> _Traceback (most recent call last):_
> 
> _File “/anaconda3/lib/python3.6/site-packages/vtkmodules/vtkRenderingQt.py”, line 5, in_
> 
> \*from .vtkRenderingQtPython import \*\*
> 
> _ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/vtkmodules/vtkRenderingQtPython.so, 2): Library not loaded: @rpath/QtWidgets.framework/Versions/5/QtWidgets_
> 
> _Referenced from: /usr/local/lib/libvtkRenderingQt-8.2.1.dylib_
> 
> _Reason: image not found_
> 
> _During handling of the above exception, another exception occurred:_
> 
> _Traceback (most recent call last):_
> 
> _File “/Users/abhishek/Documents/python/test/read\_vtk.py”, line 1, in_
> 
> _import vtk_
> 
> _File “/anaconda3/lib/python3.6/site-packages/vtk.py”, line 32, in_
> 
> _all\_spec.loader.exec\_module(all\_m)_
> 
> _File “/anaconda3/lib/python3.6/site-packages/vtkmodules/all.py”, line 100, in_
> 
> \*from .vtkRenderingQt import \*\*
> 
> _File “/anaconda3/lib/python3.6/site-packages/vtkmodules/vtkRenderingQt.py”, line 9, in_
> 
> \*from vtkRenderingQtPython import \*\*
> 
> _ModuleNotFoundError: No module named ‘vtkRenderingQtPython’_

have i missed some flag? both \*vtkRenderingQtPython.so and \*libvtkRenderingQt-8.2.1.dylib are in the paths above, what is the reason for image not found error?

thanks

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 30, 2019, 8:12pm UTC](https://discourse.vtk.org/t/vtk-build-issue-with-qt-and-python-wrapping/1053/4 "2019-05-30T20:12:41Z")

</div>

It’s saying that it can’t find `QtWidgets` based on the information available in `vtkRenderingQtPython.so`. It’s probably missing an `LC_RPATH` command entry. This can be fixed by adding the path to the Qt frameworks to the `CMAKE_INSTALL_RPATH` and/or `CMAKE_BUILD_RPATH` variable(s) when building VTK depending on which you’re using in the end.

---

<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 30, 2019, 8:54pm UTC](https://discourse.vtk.org/t/vtk-build-issue-with-qt-and-python-wrapping/1053/5 "2019-05-30T20:54:50Z")

</div>

hi, if i try to run from vtkpython exec that was created in the build bin folder it works fine, so i tried to copy the contents of site-packages folder to anaconda root site-packages folder from that point on i am getting

Fatal Python error: PyThreadState\_Get: no current thread

i am not able to understand how it is running fine from the vtkpython exec but not if i open a python terminal and try running it, it’s the same version of python in both cases, 3.6.5

thanks

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 31, 2019, 1:32pm UTC](https://discourse.vtk.org/t/vtk-build-issue-with-qt-and-python-wrapping/1053/6 "2019-05-31T13:32:28Z")

</div>

Seems that Dan answered this specific question here: [using vtk 8.2.0 with python wrappings with anaconda](https://discourse.vtk.org/t/using-vtk-8-2-0-with-python-wrappings-with-anaconda/1060)

---

<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, 2:27pm UTC](https://discourse.vtk.org/t/vtk-build-issue-with-qt-and-python-wrapping/1053/7 "2019-05-31T14:27:34Z")

</div>

hi,

in this case i am getting ModuleNotFoundError: No module named ‘vtkRenderingQtPython’ error, in the other case i am getting a different error, i thought since the errors were different i had to open different topics.

hence 2 different posts

Thanks

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [May 31, 2019, 4:34pm UTC](https://discourse.vtk.org/t/vtk-build-issue-with-qt-and-python-wrapping/1053/8 "2019-05-31T16:34:51Z")

</div>

Ah, I see. If you’re seeing the Qt loader errors, that is the root problem. You’ll need to change `CMAKE_INSTALL_RPATH` and `CMAKE_BUILD_RPATH` to include the path to your Qt installation to make the `@rpath/QtWidgets.framework/Versions/5/QtWidgets` library lookup work.
