我是集群的新手,只是安装了集群包(命令行:pip install cluster),并且想要导入集群。但出于某种原因,我不断得到这个:
>>> import cluster
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cluster/__init__.py", line 25, in <module>
__version__ = resource_string('cluster','version.txt').decode('ascii').strip()
File "/Library/Python/2.7/site-packages/setuptools-1.1.6-py2.7.egg/pkg_resources.py", line 896, in resource_string
File "/Library/Python/2.7/site-packages/setuptools-1.1.6-py2.7.egg/pkg_resources.py", line 1305, in get_resource_string
File "/Library/Python/2.7/site-packages/setuptools-1.1.6-py2.7.egg/pkg_resources.py", line 1426, in _get
IOError: [Errno 2] No such file or directory: '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cluster/version.txt'
和我的pip安装群集&#39;命令说
Requirement already satisfied (use --upgrade to upgrade): cluster in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
我有什么办法可以开始使用群集吗?我知道scipy也可能有集群功能,但是如果可能的话我想使用集群包。
谢谢!
答案 0 :(得分:0)
嗯,pypi page for 'cluster'表示您必须导入其中一种群集,如:
>>> from cluster import HierarchicalClustering
>>> data = [12,34,23,32,46,96,13]
>>> cl = HierarchicalClustering(data, lambda x,y: abs(x-y))
或
>>> from cluster import KMeansClustering
>>> cl = KMeansClustering([(1,1), (2,1), (5,3), ...])
>>> clusters = cl.getclusters(2)