我正在尝试运行以下代码,并得到一个AttributeError:'module‘对象没有'hcluster’属性,这是在最后一行中引发的。
我在Mountain Lion中运行,我使用pip和homebrew,而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)发布于 2013-10-23 21:59:24
这个错误意味着Python无法在模块hcluster中找到函数/类hcluster,所以当您执行tree = hcluster.hcluster(features)操作时,它会报错。
我不熟悉这个模块,但我快速浏览了一下,它列出了一个名为fcluster的函数,但没有hcluster。
https://stackoverflow.com/questions/19541270
复制相似问题