我尝试运行以下代码,得到一个AttributeError:“module”对象没有在最后一行中引发的属性“hcluster”。在
我在Mountain Lion中运行,我使用pip和自制程序,hcluster在PYTHONPATH=/usr/local/lib/python2.7/site-packages中。在
知道会出什么问题吗?谢谢。在
import os
import hcluster
from numpy import *
from PIL import Image
# create a list of images
path = 'data/flickr-sunsets-small'
imlist = [os.path.join(path,f) for f in os.listdir(path) if f.endswith('.jpg')]
# extract feature vector (8 bins per color channel)
features = zeros([len(imlist), 512])
for i,f in enumerate(imlist):
im = array(Image.open(f))
# multi-dimensional histogram
h,edges = histogramdd(im.reshape(-1,3),8,normed=True,range=[(0,255),(0,255),(0,255)])
features[i] = h.flatten()
tree = hcluster.hcluster(features)
此错误意味着Python在 {{cd3>当你抱怨的时候。在
我不熟悉这个模块,但我快速地看了一下这个模块,它列出了一个名为
fcluster
的函数,但没有hcluster
。在相关问题 更多 >
编程相关推荐