环境:
ubuntu18.04
conda
python3.6
pandas 0.22.0
硬件平台:armv7l
在使用指令
python setup.py install
编译pandas 0.22.0源码时,报错:
/lib/python3.6/site-packages/numpy-1.19.5-py3.6-linux-armv7l.egg/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with " \
^~~~~~~
pandas/_libs/src/ujson/python/objToJSON.c: In function 'initObjToJSON':
pandas/_libs/src/ujson/python/objToJSON.c:191:12: error: 'NUMPY_IMPORT_ARRAY_RETVAL' undeclared (first use in this function); did you mean 'NPY_INOUT_ARRAY'?
return NUMPY_IMPORT_ARRAY_RETVAL;
^~~~~~~~~~~~~~~~~~~~~~~~~
NPY_INOUT_ARRAY
pandas/_libs/src/ujson/python/objToJSON.c:191:12: note: each undeclared identifier is reported only once for each function it appears in
pandas/_libs/src/ujson/python/objToJSON.c:192:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
error: command 'gcc' failed with exit status 1
进入pandas 离线包路径:pandas-0.22.0/pandas/_libs/src/ujson/python/
在头文件py_defines.h中加入以下内容
sudo vim pandas/_libs/src/ujson/python/py_defines.h
#if PY_MAJOR_VERSION >= 3
#if PY_VERSION_HEX >= 0x03000000
#define NUMPY_IMPORT_ARRAY_RETVAL NULL
#else
#define NUMPY_IMPORT_ARRAY_RETVAL
#endif
再次安装成功 python3 setup.py install