我对此问题越来越感到沮丧,但我一直在尝试重新安装GDAL以安装新版本的QGIS。当我尝试使用pip install GDAL
安装它时,我得到以下内容:
Installing collected packages: GDAL
Running setup.py install for GDAL
building 'osgeo._gdal' extension
cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.9/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.7-x86_64-2.7/extensions/gdal_wrap.o
extensions/gdal_wrap.cpp:2230:11: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
res = SWIG_AddCast(res);
~~~ ^ ~~~
extensions/gdal_wrap.cpp:2233:11: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
res = SWIG_AddCast(res);
~~~ ^ ~~~
extensions/gdal_wrap.cpp:3515:12: error: use of undeclared identifier 'GDALGetMetadataDomainList'
return GDALGetMetadataDomainList( self );
^
extensions/gdal_wrap.cpp:3753:5: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem *vmem;
^
extensions/gdal_wrap.cpp:3761:5: error: unknown type name 'GDALTileOrganization'
GDALTileOrganization eTileOrganization;
^
extensions/gdal_wrap.cpp:3836:15: warning: unused variable 'start_addr' [-Wunused-variable]
char* start_addr = (char*)CPLVirtualMemGetAddr( self->vmem ) + start_offset;
^
extensions/gdal_wrap.cpp:4237:9: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem* vmem = GDALDatasetGetVirtualMem( self,
^
extensions/gdal_wrap.cpp:4237:31: error: use of undeclared identifier 'GDALDatasetGetVirtualMem'
CPLVirtualMem* vmem = GDALDatasetGetVirtualMem( self,
^
extensions/gdal_wrap.cpp:4263:237: error: unknown type name 'GDALTileOrganization'
SWIGINTERN CPLVirtualMemShadow *GDALDatasetShadow_GetTiledVirtualMem(GDALDatasetShadow *self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nTileXSize,int nTileYSize,GDALDataType eBufType,int band_list,int *pband_list,GDALTileOrganization eTileOrganization,size_t nCacheSize,char **options=NULL){
^
extensions/gdal_wrap.cpp:4266:9: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem* vmem = GDALDatasetGetTiledVirtualMem( self,
^
extensions/gdal_wrap.cpp:4620:9: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem* vmem = GDALRasterBandGetVirtualMem( self,
^
extensions/gdal_wrap.cpp:4620:31: error: use of undeclared identifier 'GDALRasterBandGetVirtualMem'
CPLVirtualMem* vmem = GDALRasterBandGetVirtualMem( self,
^
extensions/gdal_wrap.cpp:4647:9: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem* vmem = GDALGetVirtualMemAuto( self,
^
extensions/gdal_wrap.cpp:4647:31: error: use of undeclared identifier 'GDALGetVirtualMemAuto'
CPLVirtualMem* vmem = GDALGetVirtualMemAuto( self,
^
extensions/gdal_wrap.cpp:4667:9: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem* vmem = GDALRasterBandGetTiledVirtualMem( self,
^
extensions/gdal_wrap.cpp:4667:31: error: use of undeclared identifier 'GDALRasterBandGetTiledVirtualMem'; did you mean 'GDALRasterBandShadow_GetVirtualMem'?
CPLVirtualMem* vmem = GDALRasterBandGetTiledVirtualMem( self,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GDALRasterBandShadow_GetVirtualMem
extensions/gdal_wrap.cpp:4619:33: note: 'GDALRasterBandShadow_GetVirtualMem' declared here
SWIGINTERN CPLVirtualMemShadow *GDALRasterBandShadow_GetVirtualMem(GDALRasterBandShadow *self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nBufXSize,int nBufYSize,GDALDataType eBufType,size_t nCacheSize,size_t nPageSizeHint,char **options=NULL){
^
extensions/gdal_wrap.cpp:4685:41: error: use of undeclared identifier 'GTO_BSQ'
vmemshadow->eTileOrganization = GTO_BSQ;
^
extensions/gdal_wrap.cpp:4867:16: error: use of undeclared identifier 'GDALRATChangesAreWrittenToFile'
return GDALRATChangesAreWrittenToFile( self );
^
extensions/gdal_wrap.cpp:7845:31: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
PyObject *item_list = PyMapping_Items( obj1 );
^
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/abstract.h:1354:50: note: expanded from macro 'PyMapping_Items'
#define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL)
^
extensions/gdal_wrap.cpp:11385:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "B";
^
extensions/gdal_wrap.cpp:11390:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "h";
^
extensions/gdal_wrap.cpp:11395:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "H";
^
extensions/gdal_wrap.cpp:11400:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "i";
^
extensions/gdal_wrap.cpp:11405:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "I";
^
extensions/gdal_wrap.cpp:11410:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "f";
^
extensions/gdal_wrap.cpp:11415:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "F";
^
extensions/gdal_wrap.cpp:11420:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "B";
^
extensions/gdal_wrap.cpp:13656:3: error: unknown type name 'GDALTileOrganization'
GDALTileOrganization arg12 ;
^
extensions/gdal_wrap.cpp:13768:24: error: unknown type name 'GDALTileOrganization'
arg12 = static_cast< GDALTileOrganization >(val12);
^
extensions/gdal_wrap.cpp:23687:14: warning: explicitly assigning a variable of type 'void *' to itself [-Wself-assign]
clientdata = clientdata;
~~~~~~~~~~ ^ ~~~~~~~~~~
13 warnings and 17 errors generated.
error: command 'cc' failed with exit status 1
Complete output from command /usr/local/opt/python/bin/python2.7 -c "import setuptools;__file__='/private/var/folders/y2/thsw8bnj0xz0vp55gcykptfw0000gn/T/pip_build_root/GDAL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/y2/thsw8bnj0xz0vp55gcykptfw0000gn/T/pip-bLqvAE-record/install-record.txt --single-version-externally-managed:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-2.7
copying gdal.py -> build/lib.macosx-10.7-x86_64-2.7
copying ogr.py -> build/lib.macosx-10.7-x86_64-2.7
copying osr.py -> build/lib.macosx-10.7-x86_64-2.7
copying gdalconst.py -> build/lib.macosx-10.7-x86_64-2.7
copying gdalnumeric.py -> build/lib.macosx-10.7-x86_64-2.7
creating build/lib.macosx-10.7-x86_64-2.7/osgeo
copying osgeo/__init__.py -> build/lib.macosx-10.7-x86_64-2.7/osgeo
copying osgeo/gdal.py -> build/lib.macosx-10.7-x86_64-2.7/osgeo
copying osgeo/gdal_array.py -> build/lib.macosx-10.7-x86_64-2.7/osgeo
copying osgeo/gdalconst.py -> build/lib.macosx-10.7-x86_64-2.7/osgeo
copying osgeo/gdalnumeric.py -> build/lib.macosx-10.7-x86_64-2.7/osgeo
copying osgeo/ogr.py -> build/lib.macosx-10.7-x86_64-2.7/osgeo
copying osgeo/osr.py -> build/lib.macosx-10.7-x86_64-2.7/osgeo
running build_ext
building 'osgeo._gdal' extension
creating build/temp.macosx-10.7-x86_64-2.7
creating build/temp.macosx-10.7-x86_64-2.7/extensions
cc -fno-strict-aliasing -fno-common -dynamic -I/usr/local/include -I/usr/local/opt/sqlite/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.9/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.7-x86_64-2.7/extensions/gdal_wrap.o
extensions/gdal_wrap.cpp:2230:11: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
res = SWIG_AddCast(res);
~~~ ^ ~~~
extensions/gdal_wrap.cpp:2233:11: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
res = SWIG_AddCast(res);
~~~ ^ ~~~
extensions/gdal_wrap.cpp:3515:12: error: use of undeclared identifier 'GDALGetMetadataDomainList'
return GDALGetMetadataDomainList( self );
^
extensions/gdal_wrap.cpp:3753:5: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem *vmem;
^
extensions/gdal_wrap.cpp:3761:5: error: unknown type name 'GDALTileOrganization'
GDALTileOrganization eTileOrganization;
^
extensions/gdal_wrap.cpp:3836:15: warning: unused variable 'start_addr' [-Wunused-variable]
char* start_addr = (char*)CPLVirtualMemGetAddr( self->vmem ) + start_offset;
^
extensions/gdal_wrap.cpp:4237:9: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem* vmem = GDALDatasetGetVirtualMem( self,
^
extensions/gdal_wrap.cpp:4237:31: error: use of undeclared identifier 'GDALDatasetGetVirtualMem'
CPLVirtualMem* vmem = GDALDatasetGetVirtualMem( self,
^
extensions/gdal_wrap.cpp:4263:237: error: unknown type name 'GDALTileOrganization'
SWIGINTERN CPLVirtualMemShadow *GDALDatasetShadow_GetTiledVirtualMem(GDALDatasetShadow *self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nTileXSize,int nTileYSize,GDALDataType eBufType,int band_list,int *pband_list,GDALTileOrganization eTileOrganization,size_t nCacheSize,char **options=NULL){
^
extensions/gdal_wrap.cpp:4266:9: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem* vmem = GDALDatasetGetTiledVirtualMem( self,
^
extensions/gdal_wrap.cpp:4620:9: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem* vmem = GDALRasterBandGetVirtualMem( self,
^
extensions/gdal_wrap.cpp:4620:31: error: use of undeclared identifier 'GDALRasterBandGetVirtualMem'
CPLVirtualMem* vmem = GDALRasterBandGetVirtualMem( self,
^
extensions/gdal_wrap.cpp:4647:9: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem* vmem = GDALGetVirtualMemAuto( self,
^
extensions/gdal_wrap.cpp:4647:31: error: use of undeclared identifier 'GDALGetVirtualMemAuto'
CPLVirtualMem* vmem = GDALGetVirtualMemAuto( self,
^
extensions/gdal_wrap.cpp:4667:9: error: unknown type name 'CPLVirtualMem'
CPLVirtualMem* vmem = GDALRasterBandGetTiledVirtualMem( self,
^
extensions/gdal_wrap.cpp:4667:31: error: use of undeclared identifier 'GDALRasterBandGetTiledVirtualMem'; did you mean 'GDALRasterBandShadow_GetVirtualMem'?
CPLVirtualMem* vmem = GDALRasterBandGetTiledVirtualMem( self,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GDALRasterBandShadow_GetVirtualMem
extensions/gdal_wrap.cpp:4619:33: note: 'GDALRasterBandShadow_GetVirtualMem' declared here
SWIGINTERN CPLVirtualMemShadow *GDALRasterBandShadow_GetVirtualMem(GDALRasterBandShadow *self,GDALRWFlag eRWFlag,int nXOff,int nYOff,int nXSize,int nYSize,int nBufXSize,int nBufYSize,GDALDataType eBufType,size_t nCacheSize,size_t nPageSizeHint,char **options=NULL){
^
extensions/gdal_wrap.cpp:4685:41: error: use of undeclared identifier 'GTO_BSQ'
vmemshadow->eTileOrganization = GTO_BSQ;
^
extensions/gdal_wrap.cpp:4867:16: error: use of undeclared identifier 'GDALRATChangesAreWrittenToFile'
return GDALRATChangesAreWrittenToFile( self );
^
extensions/gdal_wrap.cpp:7845:31: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
PyObject *item_list = PyMapping_Items( obj1 );
^
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/include/python2.7/abstract.h:1354:50: note: expanded from macro 'PyMapping_Items'
#define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL)
^
extensions/gdal_wrap.cpp:11385:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "B";
^
extensions/gdal_wrap.cpp:11390:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "h";
^
extensions/gdal_wrap.cpp:11395:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "H";
^
extensions/gdal_wrap.cpp:11400:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "i";
^
extensions/gdal_wrap.cpp:11405:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "I";
^
extensions/gdal_wrap.cpp:11410:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "f";
^
extensions/gdal_wrap.cpp:11415:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "F";
^
extensions/gdal_wrap.cpp:11420:21: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
buf->format = "B";
^
extensions/gdal_wrap.cpp:13656:3: error: unknown type name 'GDALTileOrganization'
GDALTileOrganization arg12 ;
^
extensions/gdal_wrap.cpp:13768:24: error: unknown type name 'GDALTileOrganization'
arg12 = static_cast< GDALTileOrganization >(val12);
^
extensions/gdal_wrap.cpp:23687:14: warning: explicitly assigning a variable of type 'void *' to itself [-Wself-assign]
clientdata = clientdata;
~~~~~~~~~~ ^ ~~~~~~~~~~
13 warnings and 17 errors generated.
error: command 'cc' failed with exit status 1
要点是最后一行:错误:command 'cc' failed with exit status
。我已经尝试了几乎我在Stackoverflow和其他任何地方找到的修复,从导出CFLAG策略到删除文件。我仍然得到那个错误。
任何人都可以帮忙。
答案 0 :(得分:12)
我刚刚碰到这个(因此找到了你的问题)。我通过确保我尝试安装的(Python)GDAL
版本与系统上libgdal
的版本匹配来解决它。
在我的情况下,pip正在引入GDAL==1.11.0
,而我libgdal
的版本是1.10.1+dfsg-5ubuntu1
。运行pip install GDAL==1.10.0
(可能替换实际版本)应该做正确的事情。
您的编译器错误GDAL 1.11.0
期望符号仅存在于libgdal
的最新版本中。