安装fastcluster库时遇到问题,包括numpy

2024-10-03 02:48:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图安装fastclusterPython库,但遇到了编译错误。在

$ pip install fastcluster

生成以下输出:

^{pr2}$

是什么原因造成的?关于设置include目录的事情?在


Tags: installpip目录include错误原因事情pr2
1条回答
网友
1楼 · 发布于 2024-10-03 02:48:02

安装fastcluster时遇到的问题与this previous question有关-编译器没有在正确的目录中查找numpy头。您可以或多或少地使用与接受答案中给出的相同的解决方案:

  1. 下载并解压fastcluster的源代码

    $ pip install fastcluster  download='.'
    $ tar -xzf fastcluster-1.1.17.tar.gz
    $ cd fastcluster-1.1.17/
    
  2. 编辑setup.py文件,将numpy.get_include()的输出添加到Extensioninclude_dirs=参数:

    import numpy
    
    ...
    
    ext_modules=[Extension('_fastcluster',                                     
                           ['src/fastcluster_python.cpp'],                     
                           extra_compile_args=['/EHsc'] if os.name=='nt' else [],
                           include_dirs=[numpy.get_include()]
                           )]
    
  3. 安装fastcluster

    $ python setup.py install
    
  4. ^{} maintainer知道他的包裹坏了:-)

相关问题 更多 >