python setup.py build_ext –include-dirs = / usr / include / gdal / not work

python setup.py build_ext --include-dirs=/usr/include/gdal/ not work

我尝试在virstualenvwrapper中安装gdal,遵循几个指南和stackoverflow答案。

我在Ubuntu 13.04上,我发现了ligbdal1libgdal1-dev

在我的virtualenv中,我尝试过:

1
pip install --no-install GDAL

……之后:

1
python setup.py build_ext --include-dirs=/usr/include/gdal/

但我得到了这个错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
running build_ext
building 'osgeo._gdal' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/gdal/ -I/usr/include/python2.7 -I/home/envs/test/local/lib/python2.7/site-packages/numpy/core/include -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-2.7/extensions/gdal_wrap.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
extensions/gdal_wrap.cpp: In function ‘int PyProgressProxy(double, const char*, void*)’:
extensions/gdal_wrap.cpp:3237:2: warning: the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress]
extensions/gdal_wrap.cpp: In function ‘int GDALTransformerInfoShadow_TransformGeolocations(GDALTransformerInfoShadow*, GDALRasterBandShadow*, GDALRasterBandShadow*, GDALRasterBandShadow*, GDALProgressFunc, void*, char**)’:
extensions/gdal_wrap.cpp:5010:69: error: ‘GDALTransformGeolocations’ was not declared in this scope
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_GOA2GetAuthorizationURL(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:5553:79: error: ‘GOA2GetAuthorizationURL’ was not declared in this scope
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_GOA2GetRefreshToken(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:5606:94: error: ‘GOA2GetRefreshToken’ was not declared in this scope
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_GOA2GetAccessToken(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:5661:93: error: ‘GOA2GetAccessToken’ was not declared in this scope
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_ReadDirRecursive(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:6081:61: error: ‘VSIReadDirRecursive’ was not declared in this scope
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_MajorObject_SetMetadata__SWIG_0(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:7501:31: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
extensions/gdal_wrap.cpp: In function ‘int GDALTransformerInfoShadow_TransformGeolocations(GDALTransformerInfoShadow*, GDALRasterBandShadow*, GDALRasterBandShadow*, GDALRasterBandShadow*, GDALProgressFunc, void*, char**)’:
extensions/gdal_wrap.cpp:5011:3: warning: control reaches end of non-void function [-Wreturn-type]
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1`

有什么建议吗?我哪里可能出错?


Ubuntu 13.04上的libgdal1包似乎已经过时。python cheeshop(pypi,pip使用的就是pypi)提供了1.10.0包装器,而13.04包列表显示提供了libgdal版本1.9.0。显然,在1.10中,引入了许多新的函数,这就是您看到的"未声明"错误。

因此,有两种选择:

  • 手动安装libgdal 1.10。在这种情况下,您可能可以对配置脚本使用--with-python选项,并且不需要安装单独的python绑定。我想,你也能跟上最新最棒的。

  • 从python cheeshop下载一个旧的python gdal包装,然后从那里继续。这可能是最简单的选择。