python setup.py 配置 --include-dirs 在安装 h5py 时不起作用

python setup.py config --include-dirs not work when install h5py

已在此处安装 hdf5 库:~/soft/lib/packages/hdf5-1.8.14-linux-centos5-x86_64-gcc412-shared/。我使用以下命令安装 h5py:

python setup.py config --include-dirs=/panfs/home/kang/yangpc/soft/lib/packages/hdf5-1.8.14-linux-centos5-x86_64-gcc412-shared/include/ build

我也尝试在 MANIFEST.in 文件中添加一行 graft /panfs/home/kang/yangpc/soft/lib/packages/hdf5-1.8.14-linux-centos5-x86_64-gcc412-shared/include/

然后我尝试将头文件路径添加到 INCLUDE 变量中: export INCLUDE=$INCLUDE:/panfs/home/kang/yangpc/soft/lib/packages/hdf5-1.8.14-linux-centos5-x86_64-gcc412-shared/include/

然后尝试设置 CPLUS_INCLUDE_PATH 变量:export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/panfs/home/kang/yangpc/soft/include:/panfs/home/kang/yangpc/soft/lib/packages/hdf5-1.8.14-linux-centos5-x86_64-gcc412-shared/include/

它仍然给出下面列出的错误。似乎找不到库头文件。但是,我已经使用各种方法指定了目录。任何人都可以提出一些建议吗?万分感谢!

In file included from /panfs/home/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1804,
                 from /panfs/home/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
                 from /panfs/home/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from /panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/api_compat.h:26,
                 from /panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:287:
/panfs/home/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
In file included from /panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:287:
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/api_compat.h:27:18: error: hdf5.h: No such file or directory
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:290:23: error: H5Cpublic.h: No such file or directory
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:291:21: error: hdf5_hl.h: No such file or directory
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:489: error: expected specifier-qualifier-list before 'H5E_auto_t'
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:686: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__pyx_f_4h5py_4defs_H5open'
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:778: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__pyx_f_4h5py_4defs_H5close'
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:870: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__pyx_f_4h5py_4defs_H5get_libversion'
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:962: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__pyx_f_4h5py_4defs_H5Acreate'
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:1054: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__pyx_f_4h5py_4defs_H5Aopen_idx'
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:1146: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__pyx_f_4h5py_4defs_H5Aopen_name'
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:1238: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__pyx_f_4h5py_4defs_H5Aclose'
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:1330: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__pyx_f_4h5py_4defs_H5Adelete'
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:1422: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__pyx_f_4h5py_4defs_H5Aread'
/panfs/home/kang/yangpc/soft/Python/Python_packages/h5py-2.5.0/h5py/defs.c:1514: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__pyx_f_4h5py_4defs_H5Awrite'

但是,当我尝试使用 pip pip install h5py 安装时,出现以下错误:

pip install h5py
/panfs/home/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pip-7.0.0.dev0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Collecting h5py
/panfs/home/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pip-7.0.0.dev0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/panfs/home/kang/yangpc/soft/Python/python2.7/lib/python2.7/site-packages/pip-7.0.0.dev0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Could not find a version that satisfies the requirement h5py (from versions: )
  No matching distribution found for h5py

受此 [1] 问题的启发,此问题已通过以下方式解决:

export HDF5_DIR=/panfs/home/kang/yangpc/soft/lib/packages/hdf5-1.8.14-linux-centos5-x86_64-gcc412-shared/
python setup.py install --prefix=/anywhere/you/want/

此脚本应添加到 h5py 的安装 README 文档中。

[1] https://github.com/PacificBiosciences/pbcore/issues/5