SimpleElastix
SimpleElastix copied to clipboard
Getting Started instructions can lead to having multiple SimpleITKs installed
I've been installing SimpleElastix locally in a virtual environment on my Mac (macOS 10.15.4) and ran into an edge-case when SimpleITK was already installed in my virtual environment.
In that virtual environment, I had installed SimpleITK before using pip install SimpleITK
Afterwards, I followed the instructions from the Getting Started page
I had to manually turn off some of the wrapping and turn python wrapping on (defaulted to OFF) in the CMakeCache.txt
file. Then I called python Packaging/setup.py install
and it seemed to have worked, but the SimpleElastix parts did not show up in the SITK namespace.
It turns out that calling python Packaging/setup.py install
installed the 2.0.0rc of SITK, whereas my environment already contained the 1.2.4 release version. When importing SITK in python afterwards, python would default to loading the 1.2.4 version and that did not contain the SimpleElastix namespace.
I tested it by doing:
import SimpleITK as sitk
'ParameterMap' in dir(sitk)
This returns false.
I could fix this by uninstalling SITK from my virtualenv by calling pip uninstall SimpleITK
or by never having SimpleITK installed in my virtualenv.
Afterwards, if I call python Packaging/setup.py install
, it installs the 2.0.0rc version of SimpleITK and correctly links the namespace there. If I then test with 'ParameterMap' in dir(sitk)
, I get true and everything works afterwards.
Long story short, currently the only way I can get SimpleElastix working is by uninstalling SimpleITK beforehand and using the 2.0.0rc version of SimpleElastix afterwards. I assume that is not the intended workflow, but it seems to work at the moment. Maybe there is an easy fix for it? Otherwise, mentioning this in the Getting Started page would help save a lot of time for people starting to use SimpleElastix :)
I had to run another installation of it and discovered which part of Simple Elastix is installing the SimpleITK version. It's the setup.py file in {BUILD_DIRECTORY}/SimpleITK-build/Wrapping/Python/Packaging
. It specifies that sitk 2.0.0rc needs to be installed. I don't know whether this is necessary for something, but if so, it would be great to have a warning here. Otherwise, users often have 2 SimpleITKs installed and the default one doesn't have Simple Elastix integrated...
Thanks for your report @jluethi. We are currently looking into changing the name of the Python package name. That should clear up the issue and also result the confusion that often arises from the overlapping names.
Hello @kaspermarstal @jluethi ,
I have had a similar issue. I had install in my virtual env. already contained the SimpleITK 1.2.4 (Ubuntu 18.04, Python 3.6, virtualenv for virtual environment)
- When I removed it (
pip uninstall SimpleITK
) and executedpython Packaging/setup.py install
the SimpleITK 2.0.0 was loaded in my enviroment and the namespacesitk.Elastix()
is recognized but I have this error:
ModuleNotFoundError: No module named '_SimpleITK'
- When I first install SimpleITK 2.0.0 (
pip uninstall SimpleITK
) and executepython Packaging/setup.py install
afterwards I have this error:
AttributeError: module 'SimpleITK' has no attribute 'Elastix'
Any ideas what might be wrong?
In a new virtual environment the error: ModuleNotFoundError: No module named '_SimpleITK'
still exists.