Python error: module 'itk' has no attribute 'ParameterObject'

Python error: module 'itk' has no attribute 'ParameterObject'

我在 python (https://itkpythonpackage.readthedocs.io/en/master/Quick_start_guide.html) and the package seems to work, but when I want to use a code I found on github (https://github.com/InsightSoftwareConsortium/ITKElastix/blob/master/wrapping/test/itkElastixRegistrationMethodTest.py) 中使用 ITK 它给我一个错误:

import itk
parameter_object = itk.ParameterObject.New()

module 'itk' has no attribute 'ParameterObject'

不幸的是我找不到为什么我的itk没有ParameterObject属性,但我发现其他代码也使用了这个属性。我尝试升级 itk:

Requirement already satisfied: itk in /.../miniconda3/lib/python3.9/site-packages (5.2.1.post1)

我是 ITK 的新手,我不太确定我做错了什么,有人可以帮助我吗?

您需要 ITKElastix。通过 pip install itk-elastix.

获取

如果您从源代码构建 ITK,则需要从源代码构建 ITKElastix 并指向主 ITK 构建。