我在安装gdal时经历了残酷的时光。我尝试在安装了GDAL的虚拟环境Python 3.6环境中重新安装Ubuntu Mint。在完成所有依赖项要求之后,我现在在运行pip install gdal
后得到以下错误:
Collecting gdal
Using cached https://files.pythonhosted.org/packages/99/31/2e05c1be3196126fa04028aed51489f40ceea77e8361a80bc8b00fc463db/GDAL-2.3.1.tar.gz
Building wheels for collected packages: gdal
Running setup.py bdist_wheel for gdal ... error
Complete output from command /home/mnewman/pyenvs/py36/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-sxbz7tcv/gdal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp00t__5p7pip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying gdal.py -> build/lib.linux-x86_64-3.6
copying ogr.py -> build/lib.linux-x86_64-3.6
copying osr.py -> build/lib.linux-x86_64-3.6
copying gdalconst.py -> build/lib.linux-x86_64-3.6
copying gnm.py -> build/lib.linux-x86_64-3.6
copying gdalnumeric.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/osgeo
copying osgeo/gdal_array.py -> build/lib.linux-x86_64-3.6/osgeo
copying osgeo/gdalconst.py -> build/lib.linux-x86_64-3.6/osgeo
copying osgeo/__init__.py -> build/lib.linux-x86_64-3.6/osgeo
copying osgeo/gnm.py -> build/lib.linux-x86_64-3.6/osgeo
copying osgeo/osr.py -> build/lib.linux-x86_64-3.6/osgeo
copying osgeo/ogr.py -> build/lib.linux-x86_64-3.6/osgeo
copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-3.6/osgeo
copying osgeo/gdal.py -> build/lib.linux-x86_64-3.6/osgeo
Fixing build/lib.linux-x86_64-3.6/gdal.py build/lib.linux-x86_64-3.6/ogr.py build/lib.linux-x86_64-3.6/osr.py build/lib.linux-x86_64-3.6/gdalconst.py build/lib.linux-x86_64-3.6/gnm.py build/lib.linux-x86_64-3.6/gdalnumeric.py build/lib.linux-x86_64-3.6/osgeo/gdal_array.py build/lib.linux-x86_64-3.6/osgeo/gdalconst.py build/lib.linux-x86_64-3.6/osgeo/__init__.py build/lib.linux-x86_64-3.6/osgeo/gnm.py build/lib.linux-x86_64-3.6/osgeo/osr.py build/lib.linux-x86_64-3.6/osgeo/ogr.py build/lib.linux-x86_64-3.6/osgeo/gdalnumeric.py build/lib.linux-x86_64-3.6/osgeo/gdal.py
Skipping optional fixer: ws_comma
Fixing build/lib.linux-x86_64-3.6/gdal.py build/lib.linux-x86_64-3.6/ogr.py build/lib.linux-x86_64-3.6/osr.py build/lib.linux-x86_64-3.6/gdalconst.py build/lib.linux-x86_64-3.6/gnm.py build/lib.linux-x86_64-3.6/gdalnumeric.py build/lib.linux-x86_64-3.6/osgeo/gdal_array.py build/lib.linux-x86_64-3.6/osgeo/gdalconst.py build/lib.linux-x86_64-3.6/osgeo/__init__.py build/lib.linux-x86_64-3.6/osgeo/gnm.py build/lib.linux-x86_64-3.6/osgeo/osr.py build/lib.linux-x86_64-3.6/osgeo/ogr.py build/lib.linux-x86_64-3.6/osgeo/gdalnumeric.py build/lib.linux-x86_64-3.6/osgeo/gdal.py
Skipping optional fixer: ws_comma
running build_ext
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-EKG1lX/python3.6-3.6.5=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/home/mnewman/pyenvs/py36/include -I/usr/include/python3.6m -I/home/mnewman/pyenvs/py36/lib/python3.6/site-packages/numpy/core/include -I/usr/include -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o
building 'osgeo._gdal' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/extensions
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-EKG1lX/python3.6-3.6.5=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/home/mnewman/pyenvs/py36/include -I/usr/include/python3.6m -I/home/mnewman/pyenvs/py36/lib/python3.6/site-packages/numpy/core/include -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-3.6/extensions/gdal_wrap.o -I/usr/include/gdal
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
extensions/gdal_wrap.cpp: In function ‘retStringAndCPLFree* wrapper_VSIGetSignedURL(const char*, char**)’:
extensions/gdal_wrap.cpp:4067:12: error: ‘VSIGetSignedURL’ was not declared in this scope
return VSIGetSignedURL( utf8_path, options );
^~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:4067:12: note: suggested alternative: ‘VSIRewindL’
return VSIGetSignedURL( utf8_path, options );
^~~~~~~~~~~~~~~
VSIRewindL
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_GetErrorCounter(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:7465:14: error: ‘CPLGetErrorCounter’ was not declared in this scope
result = CPLGetErrorCounter();
^~~~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:7465:14: note: suggested alternative: ‘_wrap_GetErrorCounter’
result = CPLGetErrorCounter();
^~~~~~~~~~~~~~~~~~
_wrap_GetErrorCounter
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_MkdirRecursive(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:8553:16: error: ‘VSIMkdirRecursive’ was not declared in this scope
result = VSIMkdirRecursive((char const *)arg1,arg2);
^~~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:8553:16: note: suggested alternative: ‘VSIReadDirRecursive’
result = VSIMkdirRecursive((char const *)arg1,arg2);
^~~~~~~~~~~~~~~~~
VSIReadDirRecursive
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_RmdirRecursive(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:8623:16: error: ‘VSIRmdirRecursive’ was not declared in this scope
result = VSIRmdirRecursive((char const *)arg1);
^~~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:8623:16: note: suggested alternative: ‘VSIReadDirRecursive’
result = VSIRmdirRecursive((char const *)arg1);
^~~~~~~~~~~~~~~~~
VSIReadDirRecursive
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_GetActualURL(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:8788:24: error: ‘VSIGetActualURL’ was not declared in this scope
result = (char *)VSIGetActualURL((char const *)arg1);
^~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:8788:24: note: suggested alternative: ‘_wrap_GetActualURL’
result = (char *)VSIGetActualURL((char const *)arg1);
^~~~~~~~~~~~~~~
_wrap_GetActualURL
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_GetFileSystemsPrefixes(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:8962:25: error: ‘VSIGetFileSystemsPrefixes’ was not declared in this scope
result = (char **)VSIGetFileSystemsPrefixes();
^~~~~~~~~~~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:8962:25: note: suggested alternative: ‘_wrap_GetFileSystemsPrefixes’
result = (char **)VSIGetFileSystemsPrefixes();
^~~~~~~~~~~~~~~~~~~~~~~~~
_wrap_GetFileSystemsPrefixes
extensions/gdal_wrap.cpp: In function ‘PyObject* _wrap_GetFileSystemOptions(PyObject*, PyObject*)’:
extensions/gdal_wrap.cpp:9026:24: error: ‘VSIGetFileSystemOptions’ was not declared in this scope
result = (char *)VSIGetFileSystemOptions((char const *)arg1);
^~~~~~~~~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:9026:24: note: suggested alternative: ‘_wrap_GetFileSystemOptions’
result = (char *)VSIGetFileSystemOptions((char const *)arg1);
^~~~~~~~~~~~~~~~~~~~~~~
_wrap_GetFileSystemOptions
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for gdal
Running setup.py clean for gdal
Failed to build gdal
不确定我在这里缺少什么,我已经安装了所有库和-dev
版本。
答案 0 :(得分:4)
我通过以下方式解决了该问题:
gdal-bin
和libgdal-dev
的最新版本:sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt upgrade
sudo apt install gdal-bin libgdal-dev
我的gdal版本是2.2.3,所以如果这不起作用,可以专门安装该版本。
pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`