# No module named vtkmodules.vtkCommonCore

**URL:** https://discourse.slicer.org/t/no-module-named-vtkmodules-vtkcommoncore/21854
**Category:** VMTK
**Tags:** build, python
**Created:** [February 8, 2022, 4:40pm UTC](https://discourse.slicer.org/t/no-module-named-vtkmodules-vtkcommoncore/21854 "2022-02-08T16:40:59Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![n\_h](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/n_h/32/14208_2.png) [@n\_h](https://discourse.slicer.org/u/n_h)
#### Post date: [February 8, 2022, 4:40pm UTC](https://discourse.slicer.org/t/no-module-named-vtkmodules-vtkcommoncore/21854/1 "2022-02-08T16:40:59Z")

</div>

Hey,

I have recently got in touch with vmtk but I have still some issues making it work from python scripts. I would like to used it to implement an automatic segmentation and meshing workflow.

I have set up an Ubuntu 20.04 Dockerimage and build vmtk following the instructions on the `http://www.vmtk.org/download/` page to install the development version.

It is possible to run simple commands from the terminal like “vmtk vmtkimagereader -ifile ct\_scan.nii.” If I want to execute the `myscript.py`example after running chmod u+x myscript.py i get the following traceback:

```auto
File "./myscript.py", line 4, in <module> from vmtk import vmtkscripts       
File "/build/vmtk/vmtk-build/Install/lib/python3.9/site-packages/vmtk/vmtkscripts.py", line 158, in <module> exec('from '+item+' import *')   
File "<string>", line 1, in <module> File "/build/vmtk/vmtk-build/Install/lib/python3.9/site-packages/vmtk/vmtkactivetubes.py", line 19, in <module> import vtk File "/build/vmtk/vmtk-build/Install/lib/python3.9/site-packages/vtk.py", line 31, in <module> all_m = importlib.import_module('vtkmodules.all')
File "/root/miniconda3/envs/vmtk/lib/python3.6/importlib/ __init__.py", line 126, in import_module  
        return _bootstrap._gcd_import(name[level:], package, level)                                                         
File "/build/vmtk/vmtk-build/Install/lib/python3.9/site-packages/vtkmodules/all.py", line 7, in <module>                
from .vtkCommonCore import *      
       ModuleNotFoundError: No module named 'vtkmodules.vtkCommonCore' 

```

I would really appreciate some hints on how to get that working.

Thank you very much,  
Nils

---

<div class="post-metadata">

### Author: ![ramtingh](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ramtingh](https://discourse.slicer.org/u/ramtingh)
#### Post date: [February 9, 2022, 9:36am UTC](https://discourse.slicer.org/t/no-module-named-vtkmodules-vtkcommoncore/21854/2 "2022-02-09T09:36:22Z")

</div>

Might be that your script is getting executed by a different python installation? I can’t think of a scenario where the command line pype scripts can find vtk, but the python script version can’t.

---

<div class="post-metadata">

### Author: ![n\_h](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/n_h/32/14208_2.png) [@n\_h](https://discourse.slicer.org/u/n_h)
#### Post date: [February 9, 2022, 10:45am UTC](https://discourse.slicer.org/t/no-module-named-vtkmodules-vtkcommoncore/21854/3 "2022-02-09T10:45:10Z")

</div>

Thank you very much for your thoughts and the quick reply.

I had a similar idea earlier and was playing around with different python versions 3.9 or even python2.7 (which should both be supported by vmtk) and got the same error but I think that you are referring to a vmtk python version, right?  
Should I set the python version to something like: `/build/vmtk/vmtk-build/Install/lib/python3.9/` or what are you suggesting?

---

<div class="post-metadata">

### Author: ![ramtingh](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ramtingh](https://discourse.slicer.org/u/ramtingh)
#### Post date: [February 9, 2022, 10:54am UTC](https://discourse.slicer.org/t/no-module-named-vtkmodules-vtkcommoncore/21854/4 "2022-02-09T10:54:38Z")

</div>

I was wondering if there are multiple python installations (e.g. default system python and one you have installed), because if “vmtk vmtkimagereader -ifile ct\_scan.nii.” from the terminal works I would be very confused about it not being able to find vtk. `vmtkimagereader` definitely needs vtk.

I haven’t exactly tried python 2.7, but I’m pretty sure the current vmtk master branch is not going to be compatible with python 2.7. The instructions at `http://www.vmtk.org/download` were written about three years ago and aren’t necessarily accurate at this point, although the builds scripts are reasonably up to date.

How exactly are you building vmtk (superbuild?) and which versions of VTK and ITK are you using?

---

<div class="post-metadata">

### Author: ![n\_h](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/n_h/32/14208_2.png) [@n\_h](https://discourse.slicer.org/u/n_h)
#### Post date: [February 9, 2022, 11:13am UTC](https://discourse.slicer.org/t/no-module-named-vtkmodules-vtkcommoncore/21854/5 "2022-02-09T11:13:57Z")

</div>

Yes, in fact there are two versions 2.7 and 3.9.5 but the default during build and execution is 3.9 which comes from anaconda and not the system itself as i just figured out.

I am strictly following the build instructions form the download page:

```auto
mkdir vmktk-build 

cd vmktk-build 

cmake .. \

make

```

The versions are: itk 5.2 and vtk9.1  
Are here any issues that are not obvious to me?  
If not I would try to build it again ensuring that I use the system’s python as 3.9.

---

<div class="post-metadata">

### Author: ![ramtingh](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ramtingh](https://discourse.slicer.org/u/ramtingh)
#### Post date: [February 9, 2022, 11:17am UTC](https://discourse.slicer.org/t/no-module-named-vtkmodules-vtkcommoncore/21854/6 "2022-02-09T11:17:16Z")

</div>

If you’re already using anaconda, you could install it from the conda-forge channel with

```auto
conda config --add channels conda-forge
conda install vmtk 

```

Do you actually need it to be built from source?

---

<div class="post-metadata">

### Author: ![n\_h](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/n_h/32/14208_2.png) [@n\_h](https://discourse.slicer.org/u/n_h)
#### Post date: [February 9, 2022, 11:36am UTC](https://discourse.slicer.org/t/no-module-named-vtkmodules-vtkcommoncore/21854/7 "2022-02-09T11:36:42Z")

</div>

Yes and no,

I have tried to use an anaconda installation as you suggested above first but the `conda install vmtk` had some issues when using the python API that are already fixed when building from the current master.

Since I want to embed vmtk in a larger python-workflow in a dockerimage I was hoping to circumvent those issues by building it directly but this turns out to be trickier than expected xD

---

<div class="post-metadata">

### Author: ![ramtingh](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ramtingh](https://discourse.slicer.org/u/ramtingh)
#### Post date: [February 9, 2022, 11:43am UTC](https://discourse.slicer.org/t/no-module-named-vtkmodules-vtkcommoncore/21854/8 "2022-02-09T11:43:13Z")

</div>

The conda-forge version is up to date with the current master branch. You can try installing specifically the new version with `conda install vmtk=1.5` .

Otherwise you can have a look at the cmake setup for Slicer’s builds which incorporate vmtk ([https://github.com/vmtk/SlicerExtension-VMTK/blob/master/SuperBuild/External\_VMTK.cmake](https://github.com/vmtk/SlicerExtension-VMTK/blob/master/SuperBuild/External_VMTK.cmake)) or the anaconda packaging builds ([https://github.com/vmtk/vmtk/blob/master/distribution/build.sh](https://github.com/vmtk/vmtk/blob/master/distribution/build.sh)), presumably something has gone wrong during the cmake configuration
