3

我正在尝试在我的工作机器(OpenSuse x86_64)上使用 PIP 安装 Biopython(一个 python 包)。

一切都很好,直到它尝试使用 numpy 标头进行一些编译

gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -fPIC -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c Bio/Cluster/clustermodule.c -o build/temp.linux-x86_64-2.7/Bio/Cluster/clustermodule.o

在这一点上它失败了

Bio/Cluster/clustermodule.c:2:31: fatal error: numpy/arrayobject.h: No such file or directory

这是因为numpy/arrayobject.h

/usr/local/lib64/python2.7/site-packages/numpy/core/include/

并不是

/usr/lib64/python2.7/site-packages/numpy/core/include 

有没有办法更新设置包含路径(/local版本)的任何变量,无论是全局还是显式安装?

更新

一年多后,我遇到了类似的问题,只是这次.h文件根本不存在于我的系统上。.h只需从另一台机器复制到

/usr/lib64/python2.7/site-packages/numpy/core/include/numpy

目录安装很顺利。

4

1 回答 1

2

感谢@Bort,我发现这显然是一个已知错误(本地/用户空间安装无论如何都不起作用)。

setup.py通过在以下位置编辑 Biopython文件

原来的

#Add extensions that requires NumPy to build
if is_Numpy_installed():
   import numpy
   numpy_include_dir = numpy.get_include()
   EXTENSIONS.append(
      Extension('Bio.Cluster.cluster',
              ['Bio/Cluster/clustermodule.c',
               'Bio/Cluster/cluster.c'],
              include_dirs=[numpy_include_dir],
              ))
   EXTENSIONS.append(
      Extension('Bio.KDTree._CKDTree',
              ["Bio/KDTree/KDTree.c",
               "Bio/KDTree/KDTreemodule.c"],
              include_dirs=[numpy_include_dir],
              ))
   EXTENSIONS.append(
      Extension('Bio.Motif._pwm',
              ["Bio/Motif/_pwm.c"],
              include_dirs=[numpy_include_dir],
              ))

更新

#Add extensions that requires NumPy to build
if is_Numpy_installed():
   import numpy
   numpy_include_dir = numpy.get_include()
   EXTENSIONS.append(
      Extension('Bio.Cluster.cluster',
              ['Bio/Cluster/clustermodule.c',
               'Bio/Cluster/cluster.c'],
              include_dirs=[numpy_include_dir, '/usr/local/lib64/python2.7/site-packages/numpy/core/include/'],
              ))
   EXTENSIONS.append(
      Extension('Bio.KDTree._CKDTree',
              ["Bio/KDTree/KDTree.c",
               "Bio/KDTree/KDTreemodule.c"],
              include_dirs=[numpy_include_dir, '/usr/local/lib64/python2.7/site-packages/numpy/core/include/'],
              ))
   EXTENSIONS.append(
      Extension('Bio.Motif._pwm',
              ["Bio/Motif/_pwm.c"],
              include_dirs=[numpy_include_dir, '/usr/local/lib64/python2.7/site-packages/numpy/core/include/'],
              ))

然后使用 pip 从源代码安装(我重新压缩了包含更新setup.py文件的文件夹然后运行)

pip install recompressed.tar.gz

它已经安装好了。

更新 我实际上在另一台 openSUSE 机器上遇到了非常相似的问题,但是这次没有包含文件...为了解决这个问题,我从 numpy 源复制它们并使用上面的 include_dirs 更新将它们提供给它们。

于 2013-01-14T18:30:28.793 回答