AttributeError:“module”对象没有属性“ElastixImageFilter”

2024-06-11 08:14:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我跟踪了SimpleElastixthe link中的安装。当我运行以下命令安装SimpleLastix的python包装器时,它正在成功运行,可以导入包:

sudo python Packaging/setup.py install

我可以导入包并使用以下函数:

^{pr2}$

但是,一旦我从python终端退出bash,并再次切换到python终端命令行,它将无法识别函数:

user@user-XPS-8920:~/workspace/registration$ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import SimpleITK as sitk
>>> elastixImageFilter = sitk.ElastixImageFilter()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'ElastixImageFilter'
>>> 

你有什么主意可以帮忙吗?原因是什么?在


Tags: the函数py命令终端setupsudolink
2条回答

检查第一个示例中运行代码的目录~/softwares/SimpleElastix/build/SimpleITK-build/Wrapping/Python,第二个示例中~/workspace/registration。可能这没有添加到PATH/LD_LIBRARY_PATH中。使用sys.path检查path变量中是否存在该模块。在

我只能通过将以下路径添加到终端上的.bashrc来解决这个问题

export PYTHONPATH=$PYTHONPATH:/home/user/softwares/SimpleElastix/build/SimpleITK-build/Wrapping/Python

相关问题 更多 >