python安装gdal的两种方法
1.不用手动下载文件,直接执行以下命令即可
condainstallgdal
2.首先,下载gdal的whl文件 链接,官网下载比较慢,GDAL-2.2.4-cp27-cp27m-win_amd64.whl
链接:https://pan.baidu.com/s/1prPHLJKwoKK505i5qTVZ7g
提取码:egj6
有百度云可以下载,然后放入本机目录。
这里目录有两种,一是放入anaconda安装目录的Scripts目录,我的是D:\anaconda\Scripts目录;二是放入Anaconda环境的Scripts目录,我的是D:\anaconda\envs\uav\Scripts(uav是我自己的环境,可通过命令condacreate-nnamepython=3.6创建环境)。
最后,在D:\Anaconda3\Scripts目录下在空白处按住shift加右键打开cmd,输入以下命令即可。
pipinstallGDAL‑3.0.1‑cp38‑cp38‑win_amd64.whl
注:若用pip安装gdal会报错:
pipinstall-ihttps://pypi.tuna.tsinghua.edu.cn/simplegdal
报错信息如下:
Lookinginindexes:https://pypi.tuna.tsinghua.edu.cn/simple Collectinggdal Downloadinghttps://pypi.tuna.tsinghua.edu.cn/packages/26/c6/f8846ba726b37f9a1099acb5bff43c309fb913577674c1ba491f6fc60598/GDAL-3.0.1.tar.gz(576kB) |████████████████████████████████|583kB810kB/s Buildingwheelsforcollectedpackages:gdal Buildingwheelforgdal(setup.py)...error ERROR:Completeoutputfromcommand/home/dennis/miniconda3/bin/python-u-c'importsetuptools,tokenize;__file__='"'"'/tmp/pip-install-i321u6em/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/pip-wheel-aaneihet--python-tagcp37: ERROR:runningbdist_wheel runningbuild runningbuild_py creatingbuild creatingbuild/lib.linux-x86_64-3.7 copyinggdal.py->build/lib.linux-x86_64-3.7 copyingogr.py->build/lib.linux-x86_64-3.7 copyingosr.py->build/lib.linux-x86_64-3.7 copyinggdalconst.py->build/lib.linux-x86_64-3.7 copyinggdalnumeric.py->build/lib.linux-x86_64-3.7 creatingbuild/lib.linux-x86_64-3.7/osgeo copyingosgeo/gdalconst.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/gdalnumeric.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/osr.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/gnm.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/__init__.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/ogr.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/gdal.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/gdal_array.py->build/lib.linux-x86_64-3.7/osgeo Fixingbuild/lib.linux-x86_64-3.7/gdal.pybuild/lib.linux-x86_64-3.7/ogr.pybuild/lib.linux-x86_64-3.7/osr.pybuild/lib.linux-x86_64-3.7/gdalconst.pybuild/lib.linux-x86_64-3.7/gdalnumeric.pybuild/lib.linux-x86_64-3.7/osgeo/gdalconst.pybuild/lib.linux-x86_64-3.7/osgeo/gdalnumeric.pybuild/lib.linux-x86_64-3.7/osgeo/osr.pybuild/lib.linux-x86_64-3.7/osgeo/gnm.pybuild/lib.linux-x86_64-3.7/osgeo/__init__.pybuild/lib.linux-x86_64-3.7/osgeo/ogr.pybuild/lib.linux-x86_64-3.7/osgeo/gdal.pybuild/lib.linux-x86_64-3.7/osgeo/gdal_array.py Skippingoptionalfixer:ws_comma Fixingbuild/lib.linux-x86_64-3.7/gdal.pybuild/lib.linux-x86_64-3.7/ogr.pybuild/lib.linux-x86_64-3.7/osr.pybuild/lib.linux-x86_64-3.7/gdalconst.pybuild/lib.linux-x86_64-3.7/gdalnumeric.pybuild/lib.linux-x86_64-3.7/osgeo/gdalconst.pybuild/lib.linux-x86_64-3.7/osgeo/gdalnumeric.pybuild/lib.linux-x86_64-3.7/osgeo/osr.pybuild/lib.linux-x86_64-3.7/osgeo/gnm.pybuild/lib.linux-x86_64-3.7/osgeo/__init__.pybuild/lib.linux-x86_64-3.7/osgeo/ogr.pybuild/lib.linux-x86_64-3.7/osgeo/gdal.pybuild/lib.linux-x86_64-3.7/osgeo/gdal_array.py Skippingoptionalfixer:ws_comma runningbuild_ext gcc-pthread-B/home/dennis/miniconda3/compiler_compat-Wl,--sysroot=/-Wsign-compare-DNDEBUG-g-fwrapv-O3-Wall-Wstrict-prototypes-fPIC-I../../port-I../../gcore-I../../alg-I../../ogr/-I../../ogr/ogrsf_frmts-I../../gnm-I../../apps-I/home/dennis/miniconda3/include/python3.7m-I/home/dennis/miniconda3/lib/python3.7/site-packages/numpy/core/include-I/home/dennis/miniconda3/include-cgdal_python_cxx11_test.cpp-ogdal_python_cxx11_test.o gcc-pthread-B/home/dennis/miniconda3/compiler_compat-Wl,--sysroot=/-Wsign-compare-DNDEBUG-g-fwrapv-O3-Wall-Wstrict-prototypes-fPIC-I../../port-I../../gcore-I../../alg-I../../ogr/-I../../ogr/ogrsf_frmts-I../../gnm-I../../apps-I/home/dennis/miniconda3/include/python3.7m-I/home/dennis/miniconda3/lib/python3.7/site-packages/numpy/core/include-I/home/dennis/miniconda3/include-cgdal_python_cxx11_test.cpp-ogdal_python_cxx11_test.o-std=c++11 building'osgeo._gdal'extension creatingbuild/temp.linux-x86_64-3.7 creatingbuild/temp.linux-x86_64-3.7/extensions gcc-pthread-B/home/dennis/miniconda3/compiler_compat-Wl,--sysroot=/-Wsign-compare-DNDEBUG-g-fwrapv-O3-Wall-Wstrict-prototypes-fPIC-I../../port-I../../gcore-I../../alg-I../../ogr/-I../../ogr/ogrsf_frmts-I../../gnm-I../../apps-I/home/dennis/miniconda3/include/python3.7m-I/home/dennis/miniconda3/lib/python3.7/site-packages/numpy/core/include-I/home/dennis/miniconda3/include-cextensions/gdal_wrap.cpp-obuild/temp.linux-x86_64-3.7/extensions/gdal_wrap.o-std=c++11-I/home/dennis/miniconda3/include cc1plus:warning:commandlineoption‘-Wstrict-prototypes'isvalidforC/ObjCbutnotforC++ extensions/gdal_wrap.cpp:4075:1:error:‘VSIDIR'doesnotnameatype VSIDIR*wrapper_VSIOpenDir(constchar*utf8_path, ^ extensions/gdal_wrap.cpp:4123:38:error:‘VSIDIR'wasnotdeclaredinthisscope DirEntry*wrapper_VSIGetNextDirEntry(VSIDIR*dir) ^ extensions/gdal_wrap.cpp:4123:46:error:‘dir'wasnotdeclaredinthisscope DirEntry*wrapper_VSIGetNextDirEntry(VSIDIR*dir) ^ extensions/gdal_wrap.cpp:4124:1:error:expected‘,'or‘;'before‘{'token { ^ extensions/gdal_wrap.cpp:3225:7:warning:‘char*get_aligned_buffer(char*,GDALDataType)'definedbutnotused[-Wunused-function] char*get_aligned_buffer(char*data,GDALDataTypentype) ^ extensions/gdal_wrap.cpp:3244:13:warning:‘voidupdate_buffer_size(void*,char*,char*,size_t)'definedbutnotused[-Wunused-function] staticvoidupdate_buffer_size(void*obj,char*data,char*data_aligned,size_tbuf_size) ^ extensions/gdal_wrap.cpp:3299:5:warning:‘intGetUseExceptions()'definedbutnotused[-Wunused-function] intGetUseExceptions(){ ^ extensions/gdal_wrap.cpp:3305:6:warning:‘voidUseExceptions()'definedbutnotused[-Wunused-function] voidUseExceptions(){ ^ extensions/gdal_wrap.cpp:3322:6:warning:‘voidDontUseExceptions()'definedbutnotused[-Wunused-function] voidDontUseExceptions(){ ^ extensions/gdal_wrap.cpp:3370:13:warning:‘voidClearErrorState()'definedbutnotused[-Wunused-function] staticvoidClearErrorState() ^ error:command'gcc'failedwithexitstatus1 ---------------------------------------- ERROR:Failedbuildingwheelforgdal Runningsetup.pycleanforgdal Failedtobuildgdal Installingcollectedpackages:gdal Runningsetup.pyinstallforgdal...error ERROR:Completeoutputfromcommand/home/dennis/miniconda3/bin/python-u-c'importsetuptools,tokenize;__file__='"'"'/tmp/pip-install-i321u6em/gdal/setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open)(__file__);code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))'install--record/tmp/pip-record-axykekqk/install-record.txt--single-version-externally-managed--compile: ERROR:runninginstall runningbuild runningbuild_py creatingbuild creatingbuild/lib.linux-x86_64-3.7 copyinggdal.py->build/lib.linux-x86_64-3.7 copyingogr.py->build/lib.linux-x86_64-3.7 copyingosr.py->build/lib.linux-x86_64-3.7 copyinggdalconst.py->build/lib.linux-x86_64-3.7 copyinggdalnumeric.py->build/lib.linux-x86_64-3.7 creatingbuild/lib.linux-x86_64-3.7/osgeo copyingosgeo/gdalconst.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/gdalnumeric.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/osr.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/gnm.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/__init__.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/ogr.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/gdal.py->build/lib.linux-x86_64-3.7/osgeo copyingosgeo/gdal_array.py->build/lib.linux-x86_64-3.7/osgeo Fixingbuild/lib.linux-x86_64-3.7/gdal.pybuild/lib.linux-x86_64-3.7/ogr.pybuild/lib.linux-x86_64-3.7/osr.pybuild/lib.linux-x86_64-3.7/gdalconst.pybuild/lib.linux-x86_64-3.7/gdalnumeric.pybuild/lib.linux-x86_64-3.7/osgeo/gdalconst.pybuild/lib.linux-x86_64-3.7/osgeo/gdalnumeric.pybuild/lib.linux-x86_64-3.7/osgeo/osr.pybuild/lib.linux-x86_64-3.7/osgeo/gnm.pybuild/lib.linux-x86_64-3.7/osgeo/__init__.pybuild/lib.linux-x86_64-3.7/osgeo/ogr.pybuild/lib.linux-x86_64-3.7/osgeo/gdal.pybuild/lib.linux-x86_64-3.7/osgeo/gdal_array.py Skippingoptionalfixer:ws_comma Fixingbuild/lib.linux-x86_64-3.7/gdal.pybuild/lib.linux-x86_64-3.7/ogr.pybuild/lib.linux-x86_64-3.7/osr.pybuild/lib.linux-x86_64-3.7/gdalconst.pybuild/lib.linux-x86_64-3.7/gdalnumeric.pybuild/lib.linux-x86_64-3.7/osgeo/gdalconst.pybuild/lib.linux-x86_64-3.7/osgeo/gdalnumeric.pybuild/lib.linux-x86_64-3.7/osgeo/osr.pybuild/lib.linux-x86_64-3.7/osgeo/gnm.pybuild/lib.linux-x86_64-3.7/osgeo/__init__.pybuild/lib.linux-x86_64-3.7/osgeo/ogr.pybuild/lib.linux-x86_64-3.7/osgeo/gdal.pybuild/lib.linux-x86_64-3.7/osgeo/gdal_array.py Skippingoptionalfixer:ws_comma runningbuild_ext gcc-pthread-B/home/dennis/miniconda3/compiler_compat-Wl,--sysroot=/-Wsign-compare-DNDEBUG-g-fwrapv-O3-Wall-Wstrict-prototypes-fPIC-I../../port-I../../gcore-I../../alg-I../../ogr/-I../../ogr/ogrsf_frmts-I../../gnm-I../../apps-I/home/dennis/miniconda3/include/python3.7m-I/home/dennis/miniconda3/lib/python3.7/site-packages/numpy/core/include-I/home/dennis/miniconda3/include-cgdal_python_cxx11_test.cpp-ogdal_python_cxx11_test.o gcc-pthread-B/home/dennis/miniconda3/compiler_compat-Wl,--sysroot=/-Wsign-compare-DNDEBUG-g-fwrapv-O3-Wall-Wstrict-prototypes-fPIC-I../../port-I../../gcore-I../../alg-I../../ogr/-I../../ogr/ogrsf_frmts-I../../gnm-I../../apps-I/home/dennis/miniconda3/include/python3.7m-I/home/dennis/miniconda3/lib/python3.7/site-packages/numpy/core/include-I/home/dennis/miniconda3/include-cgdal_python_cxx11_test.cpp-ogdal_python_cxx11_test.o-std=c++11 building'osgeo._gdal'extension creatingbuild/temp.linux-x86_64-3.7 creatingbuild/temp.linux-x86_64-3.7/extensions gcc-pthread-B/home/dennis/miniconda3/compiler_compat-Wl,--sysroot=/-Wsign-compare-DNDEBUG-g-fwrapv-O3-Wall-Wstrict-prototypes-fPIC-I../../port-I../../gcore-I../../alg-I../../ogr/-I../../ogr/ogrsf_frmts-I../../gnm-I../../apps-I/home/dennis/miniconda3/include/python3.7m-I/home/dennis/miniconda3/lib/python3.7/site-packages/numpy/core/include-I/home/dennis/miniconda3/include-cextensions/gdal_wrap.cpp-obuild/temp.linux-x86_64-3.7/extensions/gdal_wrap.o-std=c++11-I/home/dennis/miniconda3/include cc1plus:warning:commandlineoption‘-Wstrict-prototypes'isvalidforC/ObjCbutnotforC++ extensions/gdal_wrap.cpp:4075:1:error:‘VSIDIR'doesnotnameatype VSIDIR*wrapper_VSIOpenDir(constchar*utf8_path, ^ extensions/gdal_wrap.cpp:4123:38:error:‘VSIDIR'wasnotdeclaredinthisscope DirEntry*wrapper_VSIGetNextDirEntry(VSIDIR*dir) ^ extensions/gdal_wrap.cpp:4123:46:error:‘dir'wasnotdeclaredinthisscope DirEntry*wrapper_VSIGetNextDirEntry(VSIDIR*dir) ^ extensions/gdal_wrap.cpp:4124:1:error:expected‘,'or‘;'before‘{'token { ^ extensions/gdal_wrap.cpp:3225:7:warning:‘char*get_aligned_buffer(char*,GDALDataType)'definedbutnotused[-Wunused-function] char*get_aligned_buffer(char*data,GDALDataTypentype) ^ extensions/gdal_wrap.cpp:3244:13:warning:‘voidupdate_buffer_size(void*,char*,char*,size_t)'definedbutnotused[-Wunused-function] staticvoidupdate_buffer_size(void*obj,char*data,char*data_aligned,size_tbuf_size) ^ extensions/gdal_wrap.cpp:3299:5:warning:‘intGetUseExceptions()'definedbutnotused[-Wunused-function] intGetUseExceptions(){ ^ extensions/gdal_wrap.cpp:3305:6:warning:‘voidUseExceptions()'definedbutnotused[-Wunused-function] voidUseExceptions(){ ^ extensions/gdal_wrap.cpp:3322:6:warning:‘voidDontUseExceptions()'definedbutnotused[-Wunused-function] voidDontUseExceptions(){ ^ extensions/gdal_wrap.cpp:3370:13:warning:‘voidClearErrorState()'definedbutnotused[-Wunused-function] staticvoidClearErrorState() ^ error:command'gcc'failedwithexitstatus1 ---------------------------------------- ERROR:Command"/home/dennis/miniconda3/bin/python-u-c'importsetuptools,tokenize;__file__='"'"'/tmp/pip-install-i321
总结
以上所述是小编给大家介绍的python安装gdal的两种方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。