Scipy中缺少ndimage模块。

33
我正在尝试使用scipy中的ndimage库,但显然它没有安装成功。我已经分别从numpy和scipy运行了测试,并且结果都良好。我使用的是从sourceforge官方软件包安装的numpy 1.6.1和scipy 0.10.0版本。
运行:
import numpy
import scipy
import pprint

print(scipy.version.version)
print(numpy.version.version)

img = scipy.ndimage.imread("")

提供

0.10.0
1.6.1
Traceback (most recent call last):
  File "extract.py", line 8, in <module>
    img = scipy.ndimage.imread("")
AttributeError: 'module' object has no attribute 'ndimage'
4个回答

65

你需要导入这个模块:

import scipy.ndimage

1
我遇到了同样的问题,现在使用您的方法已经解决了。但是在我的ipython解释器中,import scipy之后,使用scipy.ndimage.filters.gaussian_filter1d不会抛出错误。为什么会这样? - Shuai Zhang
请参阅 https://docs.scipy.org/doc/scipy/reference/index.html#guidelines-for-importing-functions-from-scipy 了解详细信息。 - maggie

18

模块应该像这样导入:

from  scipy import ndimage

你确定这个语法正确吗? - ouflak

1

-2

在scipy中找到init文件并添加import ndimage


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接