2

我从http://pypi.python.org/pypi/hcluster下载 hcluster ,然后解压缩到一个文件夹,然后键入"python setup.py install". 似乎还可以,因为它显示:

Z:\>python setup.py install
running install
running build
running build_py
running build_ext
building '_hierarchy_wrap' extension
error: None

但我尝试“导入 hcluster”,它显示:

In [2]: import hcluster
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-002633efa200> in <module>()
----> 1 import hcluster

D:\Python\lib\site-packages\hcluster\__init__.py in <module>()
----> 1 import hierarchy as _h
      2 import distance as _d
      3 from hierarchy import *
      4 from distance import *
      5 from inspect import getmembers

D:\Python\lib\site-packages\hcluster\hierarchy.py in <module>()
    196
    197 import numpy as np
--> 198 import _hierarchy_wrap, types
    199 import hcluster.distance as distance
    200

ImportError: No module named _hierarchy_wrap

我是一个为 Python 模块构建、编译、安装等的新手,有人可以详细说明如何解决这个问题吗?谢谢

(我使用的是 Windows XP 和 Python 2.6.1)

4

1 回答 1

4

您在 Windows 上,并且在 distutils 中遇到了一个错误,该错误会阻止您看到实际问题):

set DISTUTILS_DEBUG=1
python setup.py ....

我怀疑你会没有安装与 Visual Studio 相关的东西。如果您使用的是python 2.7,则需要安装VS 2008,然后重新运行setup.py 在python 3.x上,您需要更新的版本(但我不确定是最新的2010还是2012)。

另一个更简单的解决方案是安装 mingw,然后执行以下操作:

python setup.py build_ext -c mingw32

一个更简单的解决方案是检查您需要的功能是否不在 scipy.cluster 中,它有一个适用于 Windows 的二进制安装程序。Damian Eads(hcluster 的作者)对该模块做出了相当大的贡献,并且有很大的重叠。

于 2013-01-19T14:35:38.573 回答