# Building dicom

**URL:** https://discourse.vtk.org/t/building-dicom/5420
**Category:** Development
**Created:** [March 22, 2021, 12:21pm UTC](https://discourse.vtk.org/t/building-dicom/5420 "2021-03-22T12:21:56Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![djduke](https://discourse.vtk.org/user_avatar/discourse.vtk.org/djduke/32/2174_2.png) [@djduke](https://discourse.vtk.org/u/djduke)
#### Post date: [March 22, 2021, 12:21pm UTC](https://discourse.vtk.org/t/building-dicom/5420/1 "2021-03-22T12:21:57Z")

</div>

I’ve just tried building the vtk-dicom library from David Gobbi.  
I have VTK freshly built from git sources, configured with  
shared-objects on and wrap-python on [using Python 3]. Building the DICOM library is fine however when it comes to try using the Python bindings I get  
ModuleNotFoundError: No module named ‘vtkDICOMPython’  
I can’t locate a dylib in the DICOM build area, so it would be useful to know

- where should the Python library files be found after install?
- are there any PATH setting s that need updating?  
I’,m building on OSX 11.1  
cmake version 3.19.6  
Python 3.9.1

I’m not desperate to use DICOM per se but I was hoping to use the library sources as a guide to resolvesome issues with a different library.

thanks  
David.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [March 22, 2021, 2:00pm UTC](https://discourse.vtk.org/t/building-dicom/5420/2 "2021-03-22T14:00:08Z")

</div>

The Python module has a “.so” suffix, even on macOS, and is called “vtkDICOM”. The “Python” suffix was removed from all vtk-python modules as of VTK 9.

For details on loading the module, see Testing/TestDICOMPython.py (and Testing/CMakeLists.txt).

Hope this helps,  
David

---

<div class="post-metadata">

### Author: ![djduke](https://discourse.vtk.org/user_avatar/discourse.vtk.org/djduke/32/2174_2.png) [@djduke](https://discourse.vtk.org/u/djduke)
#### Post date: [March 23, 2021, 10:37am UTC](https://discourse.vtk.org/t/building-dicom/5420/3 "2021-03-23T10:37:20Z")

</div>

Thanks David,  
I’ve been through there but with no effect. For information. I’m not seeing a vtkDICOMPython\* any where what I get after make  
is  
in the lib subdir

cmake libvtkDICOM.0.8.12.dylib libvtkDICOM.a python3.10 vtk

libdicomcli.a libvtkDICOM.1.dylib libvtkDICOM.dylib python3.9

In lib/python3.10/site-packages/

vtk

I didn’t see any failure after make [install]. Have I forgotten to do something?

thanks,

David

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [March 23, 2021, 2:01pm UTC](https://discourse.vtk.org/t/building-dicom/5420/4 "2021-03-23T14:01:59Z")

</div>

For VTK 9, there is no vtkDICOMPython anything. The Python module will be vtkDICOM.so. In my vtk-dicom build tree, it is located here:

```auto
lib/python3.7/site-packages/vtk/modules/vtkDICOM.so

```

Its use requires setting the Python path. If it isn’t being built, then make sure that `BUILD_PYTHON_WRAPPERS=ON` is enabled in your configuration (it should be enabled automatically if you built VTK itself with `VTK_WRAP_PYTHON`).

Don’t trust “make install” to do the right thing for vtk-dicom, because I still haven’t fully updated it for VTK 9. In general, the best way to build & use vtk-dicom is to enable it as a remote module during the VTK build. If built this way, it will be properly installed along with the rest of the VTK python modules.

---

<div class="post-metadata">

### Author: ![djduke](https://discourse.vtk.org/user_avatar/discourse.vtk.org/djduke/32/2174_2.png) [@djduke](https://discourse.vtk.org/u/djduke)
#### Post date: [March 23, 2021, 4:11pm UTC](https://discourse.vtk.org/t/building-dicom/5420/5 "2021-03-23T16:11:07Z")

</div>

Making progress, I’ve now confirmed that I have vtkDICOM.so  
in /usr/local/lib/python3.9/site-packages/vtk/modules/  
However vtkpython isstill not lodading it

> > > import vtk

Traceback (most recent call last):

File “”, line 1, in

File “/usr/local/lib/python3.9/site-packages/vtk.py”, line 30, in

all\_m = importlib.import\_module(‘vtkmodules.all’)

File “/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/ **init**.py”, line 127, in import\_module

return \_bootstrap.\_gcd\_import(name[level:], package, level)

File “/usr/local/lib/python3.9/site-packages/vtkmodules/all.py”, line 20, in

from .vtkViewsCore import \*

ImportError: dlopen(/usr/local/lib/python3.9/site-packages/vtkmodules/[vtkViewsCore.cpython-39-darwin.so](http://vtkViewsCore.cpython-39-darwin.so), 2): Symbol not found: \_iconv

Referenced from: /usr/lib/libarchive.2.dylib

Expected in: /usr/local/lib//libiconv.2.dylib

in /usr/lib/libarchive.2.dylib

> > > import vtkDICOM

Traceback (most recent call last):

File “”, line 1, in

ModuleNotFoundError: No module named ‘vtkDICOM’

I’m not sure why the \_iconv error isappearing.  
I’ve checked PYTHONPATH, LD\_LIBRARY\_PATH, and DYLD-LIBRARY\_PATH.

Could I check what version of Python do you have, from where?

thanks again  
David

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [March 23, 2021, 5:28pm UTC](https://discourse.vtk.org/t/building-dicom/5420/6 "2021-03-23T17:28:13Z")

</div>

An `import vtk` will only load modules that were part of the VTK build. There isn’t any way for third-party modules such as vtk-dicom to insert themselves after-the-fact.

Take a look at the [`TestDICOMPython.py`](https://github.com/dgobbi/vtk-dicom/blob/master/Testing/TestDICOMPython.py) script to see an example of how the module can be loaded. But as I mentioned in my previous post, you can’t trust the “make install” for vtk-dicom to put everything in the right place. In order to `import vtkDICOM` you must manually place `vtkDICOM.so` somewhere within the python path, or set the `PYTHONPATH` variable.

I’m using python-3.8, installed via the [python.org](http://python.org) installer.

I haven’t ever encountered a missing `_iconv` symbol, and I’m not aware of how vtkViewsCore uses iconv. It’s very unlikely to be related to Python. Either the VTK::ViewsCore module is missing a necessary dependency, or else there is some kind of symbol visibility issue.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [March 23, 2021, 5:56pm UTC](https://discourse.vtk.org/t/building-dicom/5420/7 "2021-03-23T17:56:16Z")

</div>

Regarding the `_iconv` symbol error for `/usr/lib/libarchive.2.dylib`, the only VTK module that uses libarchive is VTK::CommonArchive. So it’s very strange that the error occurred during the loading of vtkViewsCore.

Can you try loading the modules individually?

```python
import vtkmodules.vtkCommonCore
import vtkmodules.vtkCommonArchive
import vtkmodules.vtkViewsCore

```

---

<div class="post-metadata">

### Author: ![djduke](https://discourse.vtk.org/user_avatar/discourse.vtk.org/djduke/32/2174_2.png) [@djduke](https://discourse.vtk.org/u/djduke)
#### Post date: [March 23, 2021, 6:42pm UTC](https://discourse.vtk.org/t/building-dicom/5420/8 "2021-03-23T18:42:39Z")

</div>

thanks David. I’m painfully familiar with is problem from other systems on OSX but sadly thats the only system I have access to these days :-(.  
I think I triggered the problem by modifying my path vars. Once I’ve restore iconv sanity I’ll get back to looking at TestDICOMPython.  
Many thanks for taking the time to respond.  
best regards  
David
