错误构建h5py:已弃用numpy

时间:2015-03-27 19:47:44

标签: python numpy version deprecated h5py

我正在尝试使用以下方法从终端构建h5py:       git clone http://github.com/h5py/h5py.git, 然后cd / h5py,然后

     sudo python setup.py install.

它似乎开始构建但后来遇到某种错误而无法构建。请看下面的日志:

> In file included from
> /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1803:0,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
>                  from /home/user/h5py/h5py/api_compat.h:26,
>                  from /home/user/h5py/h5py/defs.c:287: /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:12:2:
> warning: #warning "Using deprecated NumPy API, disable it by #defining
> NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]  #warning "Using
> deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API
> NPY_1_7_API_VERSION"   ^
> /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:24:2:
> error: #error Should never include npy_deprecated_api directly. 
> #error Should never include npy_deprecated_api directly.   ^ In file included from
> /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:127:0,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1803,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
>                  from /home/user/h5py/h5py/api_compat.h:26,
>                  from /home/user/h5py/h5py/defs.c:287: /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/old_defines.h:5:0:
> warning: "NPY_NO_DEPRECATED_API" redefined [enabled by default] 
> #define NPY_NO_DEPRECATED_API NPY_1_9_API_VERSION  ^ In file included from
> /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1803:0,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
>                  from /home/user/h5py/h5py/api_compat.h:26,
>                  from /home/user/h5py/h5py/defs.c:287: /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:3:0:
> note: this is the location of the previous definition  #define
> NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION  ^ In file included from
> /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:127:0,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1803,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
>                  from /home/user/h5py/h5py/api_compat.h:26,
>                  from /home/user/h5py/h5py/defs.c:287: /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/old_defines.h:7:2:
> error: #error The header "old_defines.h" is deprecated as of NumPy
> 1.7.  #error The header "old_defines.h" is deprecated as of NumPy 1.7.   ^ In file included from
> /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:26:0,
>                  from /home/user/.local/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
>                  from /home/user/h5py/h5py/api_compat.h:26,
>                  from /home/user/h5py/h5py/defs.c:287: /home/saliba/.local/lib/python2.7/site-packages/numpy/core/include/numpy/__multiarray_api.h:1629:1:
> warning: ‘_import_array’ defined but not used [-Wunused-function] 
> _import_array(void)  ^ error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

有关如何修复弃用的任何想法?我有numpy版本1.9.2并尝试降级1.7.1但没有找到方法。

谢谢:D

1 个答案:

答案 0 :(得分:2)

我刚刚安装了h5py,是的,numpy是一种依赖。

numpy==1.11.2
h5py==2.6.0

由于缺少hdf5开发库,我遇到了h5py安装失败 - 在stdout上也有numpy api弃用警告:

/home/ahmed/virtualenvs/venv_anytime_rc/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" [-Wcpp]
     #warning "Using deprecated NumPy API, disable it by " \

失败的主要原因是缺少hdf5开发库,一旦安装了软件包

就解决了

对于CentOS

sudo yum -y install hdf5-devel

对于Ubuntu

sudo apt-get install libhdf5-dev

注意:上面的命令会安装hdf5开发lib版本1.8.12