edgar
August 17, 2022, 11:31am
1
Hi!
I just want to report that if I install:
pip uninstall -y itk{,-{,elastix,tubetk,strain,core,filtering,io,minimalpathextraction,numerics,registration,segmentation}} && pip install -U pip && pip cache purge && pip install itk{==5.3rc4,-{elastix,strain}}
then this works:
parameter_object = itk.ParameterObject.New()
Otherwise, I get this error:
>>> parameter_object = itk.ParameterObject.New()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/edgar/.local/lib/python3.10/site-packages/itk/support/lazy.py", line 138, in __getattribute__
base.itk_load_swig_module(module, namespace)
File "/home/edgar/.local/lib/python3.10/site-packages/itk/support/base.py", line 132, in itk_load_swig_module
l_module = loader.load(swig_module_name)
File "/home/edgar/.local/lib/python3.10/site-packages/itk/support/base.py", line 291, in load
l_spec.loader.exec_module(l_module) # pytype: disable=attribute-error
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/edgar/.local/lib/python3.10/site-packages/itk/support/../ElastixPython.py", line 13, in <module>
from . import _ElastixPython
AttributeError: PyCapsule_Import "_ITKCommonPython._C_API" is not valid
(with itk-5.3rc4.post2
)
Cheers!
dzenanz
(Dženan Zukić)
August 17, 2022, 1:49pm
2
Thanks for reporting, but it looks like a duplicate of:
opened 04:25PM - 04 Aug 22 UTC
type:Bug
<!-- The text within this markup is a comment, and is intended to provide
guide… lines to open an issue for the ITK repository. This text will not
be part of the issue. -->
<!-- Before submitting an issue, please check that your issue has not been
already filed. -->
### Description
Python module loading change introduced in [https://github.com/InsightSoftwareConsortium/ITK/commit/835dc01388d22c4b4c9a46b01dbdfe394ec23511](https://github.com/InsightSoftwareConsortium/ITK/commit/835dc01388d22c4b4c9a46b01dbdfe394ec23511) appears to break backwards compatibility with ITK Python external modules targeting an older version of ITK.
### Steps to Reproduce
<!--
1. [First Step]
2. [Second Step]
3. [and so on...]
Provide a minimal, complete, compilable, and verifiable example (commonly
abbreviated as MWE, Minimal Working Example, or sometimes referred to as SSEE,
Short, Self Contained, Correct (Compilable) Example, SSCCE) or code snippet,
either through a GitHub gist (https://gist.github.com/) or providing your own
files (including your source code, `CMakeLists.txt` file if applicable, and your
data) reproducing the issue or showing an incorrect result. -->
1. Install external module package. Tested with `itk-meshtopolydata`, `itk-elastix`, `itk-ultrasound`
2. In a Python console try to force load modules with verbosity on
```
> import itk
> itk.auto_progress(2)
> itk.force_load()
```
### Expected behavior
Modules load without error. With `itk-meshtopolydata==0.8.4` which is built against the ITK Python `v5.3rc04.post2` tag including the relevant commit:
```
>>> itk.force_load()
Loading ITKPyBase... done
Loading ITKCommon... done
...
Loading ITKIOTransformMatlab... done
done
Loading MeshToPolyData... done
Loading ITKDeconvolution... done
Loading ITKWatersheds... done
...
Loading ITKIOSpatialObjects... done
Loading ITKVTK... done
```
### Actual behavior
Error on load. With `itk-meshtopolydata==0.8.3` which is built against the `v5.3rc04.post1` ITK Python tag not including the relevant commit:
```none
>>> itk.force_load()
...
Loading ITKIOTransformMatlab... done
done
Loading MeshToPolyData... Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\tom.birdsong\Anaconda3\envs\venv-itk\lib\site-packages\itk\support\init_helpers.py", line 116, in force_load
getattr(itk, k)
File "C:\Users\tom.birdsong\Anaconda3\envs\venv-itk\lib\site-packages\itk\support\lazy.py", line 138, in __getattribute__
base.itk_load_swig_module(module, namespace)
File "C:\Users\tom.birdsong\Anaconda3\envs\venv-itk\lib\site-packages\itk\support\base.py", line 132, in itk_load_swig_module
l_module = loader.load(swig_module_name)
File "C:\Users\tom.birdsong\Anaconda3\envs\venv-itk\lib\site-packages\itk\support\base.py", line 291, in load
l_spec.loader.exec_module(l_module) # pytype: disable=attribute-error
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\tom.birdsong\Anaconda3\envs\venv-itk\lib\site-packages\itk\support\..\MeshToPolyDataPython.py", line 13, in <module>
from . import _MeshToPolyDataPython
AttributeError: PyCapsule_Import "_ITKCommonPython._C_API" is not valid
```
### Reproducibility
100%
### Versions
<!-- If a tagged version, you can get this information by inspecting the
`ITK_VERSION_MAJOR` `ITK_VERSION_MINOR` and `ITK_VERSION_PATCH` variable
values in the `ITKConfig.cmake` file.
If the commit number is required, run `$ git rev-parse --short HEAD`. -->
ITK version: `itk==v5.3rc04.post2`
### Environment
<!-- Which your OS, CMake, and compiler versions are, or your Python and
installed package versions are. -->
Windows 10
Python 3.8.5
Incompatible: `itk-meshtopolydata==v0.8.3`
Incompatible: `itk-ultrasound==v0.5.6`
Incompatible: `itk-elastix==0.14.1`
### Additional Information
<!-- Any additional information, configuration or data that might be necessary
to reproduce the issue. -->
My understanding is that [https://github.com/InsightSoftwareConsortium/ITK/commit/835dc01388d22c4b4c9a46b01dbdfe394ec23511](https://github.com/InsightSoftwareConsortium/ITK/commit/835dc01388d22c4b4c9a46b01dbdfe394ec23511) is an important fix. This behavior may be determined to be an acceptable tradeoff with a heightened focus on getting remote modules updated for `v5.3rc04.post2` or later.
cc @thewtex @jcfr
<!-- **Note**: Use issues for their purpose; issues are not for code help. Need
help? Ask your question at ITK discourse (https://discourse.itk.org/). -->
edgar
August 18, 2022, 3:25pm
3
Yes, indeed. I’m glad that it is being addressed . (I will try to remember to check the repository next time).