有没有一种很好的方法可以在不创建虚拟环境的情况下平稳运行SimpleITK库?

时间:2020-05-19 17:37:15

标签: python python-3.x virtualenv itk simpleitk

我使用SimpleITK安装了ITK版本1.2.4,pip版本4.13库,当我运行以下代码来读取Nifti image时,出现以下错误: line 4, in loadSimpleITK result = sitk.ReadImage(path) AttributeError: module 'SimpleITK' has no attribute 'ReadImage'

在库website上提出的解决方案是安装虚拟环境。

是否有另一种简单的方法可以避免使用虚拟环境来解决问题?

编辑: print(sitk)print(dir(sitk))给出了结果:

<module 'SimpleITK' from 'D:\\My_Project\\SimpleITK.py'>
['__builtins__', '__cached__', '__doc__', '__file__',
 '__loader__', '__name__', '__package__', '__spec__', 'nib', 'sitk']
<module 'SimpleITK' from 'D:\\My_Project\\SimpleITK.py'>
['__builtins__', '__cached__', '__doc__', '__file__',
 '__loader__', '__name__', '__package__', '__spec__', 'loadSimpleITK', 'nib', 'sitk']

代码:

import SimpleITK as sitk

def loadSimpleITK(path):
    result =  sitk.ReadImage(path)
    return result

path = 'mypath'
img2 = loadSimpleITK(path)

0 个答案:

没有答案