python安装gdal的两种方法


Posted in Python onOctober 29, 2019

1.不用手动下载文件,直接执行以下命令即可

conda install gdal

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是我自己的环境,可通过命令conda create -n name python=3.6创建环境)。

最后,在D:\Anaconda3\Scripts目录下在空白处按住shift加右键打开cmd,输入以下命令即可。

pip install GDAL‑3.0.1‑cp38‑cp38‑win_amd64.whl

注:若用pip安装gdal会报错:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gdal

报错信息如下:

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting gdal
 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/26/c6/f8846ba726b37f9a1099acb5bff43c309fb913577674c1ba491f6fc60598/GDAL-3.0.1.tar.gz (576kB)
  |????????????????????????????????| 583kB 810kB/s 
Building wheels for collected packages: gdal
 Building wheel for gdal (setup.py) ... error
 ERROR: Complete output from command /home/dennis/miniconda3/bin/python -u -c 'import setuptools, 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-tag cp37:
 ERROR: running bdist_wheel
 running build
 running build_py
 creating build
 creating build/lib.linux-x86_64-3.7
 copying gdal.py -> build/lib.linux-x86_64-3.7
 copying ogr.py -> build/lib.linux-x86_64-3.7
 copying osr.py -> build/lib.linux-x86_64-3.7
 copying gdalconst.py -> build/lib.linux-x86_64-3.7
 copying gdalnumeric.py -> build/lib.linux-x86_64-3.7
 creating build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/gdalconst.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/osr.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/gnm.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/__init__.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/ogr.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/gdal.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/gdal_array.py -> build/lib.linux-x86_64-3.7/osgeo
 Fixing build/lib.linux-x86_64-3.7/gdal.py build/lib.linux-x86_64-3.7/ogr.py build/lib.linux-x86_64-3.7/osr.py build/lib.linux-x86_64-3.7/gdalconst.py build/lib.linux-x86_64-3.7/gdalnumeric.py build/lib.linux-x86_64-3.7/osgeo/gdalconst.py build/lib.linux-x86_64-3.7/osgeo/gdalnumeric.py build/lib.linux-x86_64-3.7/osgeo/osr.py build/lib.linux-x86_64-3.7/osgeo/gnm.py build/lib.linux-x86_64-3.7/osgeo/__init__.py build/lib.linux-x86_64-3.7/osgeo/ogr.py build/lib.linux-x86_64-3.7/osgeo/gdal.py build/lib.linux-x86_64-3.7/osgeo/gdal_array.py
 Skipping optional fixer: ws_comma
 Fixing build/lib.linux-x86_64-3.7/gdal.py build/lib.linux-x86_64-3.7/ogr.py build/lib.linux-x86_64-3.7/osr.py build/lib.linux-x86_64-3.7/gdalconst.py build/lib.linux-x86_64-3.7/gdalnumeric.py build/lib.linux-x86_64-3.7/osgeo/gdalconst.py build/lib.linux-x86_64-3.7/osgeo/gdalnumeric.py build/lib.linux-x86_64-3.7/osgeo/osr.py build/lib.linux-x86_64-3.7/osgeo/gnm.py build/lib.linux-x86_64-3.7/osgeo/__init__.py build/lib.linux-x86_64-3.7/osgeo/ogr.py build/lib.linux-x86_64-3.7/osgeo/gdal.py build/lib.linux-x86_64-3.7/osgeo/gdal_array.py
 Skipping optional fixer: ws_comma
 running build_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 -c gdal_python_cxx11_test.cpp -o gdal_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 -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o -std=c++11
 building 'osgeo._gdal' extension
 creating build/temp.linux-x86_64-3.7
 creating build/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 -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-3.7/extensions/gdal_wrap.o -std=c++11 -I/home/dennis/miniconda3/include
 cc1plus: warning: command line option ‘-Wstrict-prototypes' is valid for C/ObjC but not for C++
 extensions/gdal_wrap.cpp:4075:1: error: ‘VSIDIR' does not name a type
 VSIDIR* wrapper_VSIOpenDir( const char * utf8_path,
 ^
 extensions/gdal_wrap.cpp:4123:38: error: ‘VSIDIR' was not declared in this scope
 DirEntry* wrapper_VSIGetNextDirEntry(VSIDIR* dir)
          ^
 extensions/gdal_wrap.cpp:4123:46: error: ‘dir' was not declared in this scope
 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)' defined but not used [-Wunused-function]
 char* get_aligned_buffer(char* data, GDALDataType ntype)
   ^
 extensions/gdal_wrap.cpp:3244:13: warning: ‘void update_buffer_size(void*, char*, char*, size_t)' defined but not used [-Wunused-function]
 static void update_buffer_size(void* obj, char* data, char* data_aligned, size_t buf_size)
    ^
 extensions/gdal_wrap.cpp:3299:5: warning: ‘int GetUseExceptions()' defined but not used [-Wunused-function]
 int GetUseExceptions() {
  ^
 extensions/gdal_wrap.cpp:3305:6: warning: ‘void UseExceptions()' defined but not used [-Wunused-function]
 void UseExceptions() {
  ^
 extensions/gdal_wrap.cpp:3322:6: warning: ‘void DontUseExceptions()' defined but not used [-Wunused-function]
 void DontUseExceptions() {
  ^
 extensions/gdal_wrap.cpp:3370:13: warning: ‘void ClearErrorState()' defined but not used [-Wunused-function]
 static void ClearErrorState()
    ^
 error: command 'gcc' failed with exit status 1
 ----------------------------------------
 ERROR: Failed building wheel for gdal
 Running setup.py clean for gdal
Failed to build gdal
Installing collected packages: gdal
 Running setup.py install for gdal ... error
 ERROR: Complete output from command /home/dennis/miniconda3/bin/python -u -c 'import setuptools, 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: running install
 running build
 running build_py
 creating build
 creating build/lib.linux-x86_64-3.7
 copying gdal.py -> build/lib.linux-x86_64-3.7
 copying ogr.py -> build/lib.linux-x86_64-3.7
 copying osr.py -> build/lib.linux-x86_64-3.7
 copying gdalconst.py -> build/lib.linux-x86_64-3.7
 copying gdalnumeric.py -> build/lib.linux-x86_64-3.7
 creating build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/gdalconst.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/osr.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/gnm.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/__init__.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/ogr.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/gdal.py -> build/lib.linux-x86_64-3.7/osgeo
 copying osgeo/gdal_array.py -> build/lib.linux-x86_64-3.7/osgeo
 Fixing build/lib.linux-x86_64-3.7/gdal.py build/lib.linux-x86_64-3.7/ogr.py build/lib.linux-x86_64-3.7/osr.py build/lib.linux-x86_64-3.7/gdalconst.py build/lib.linux-x86_64-3.7/gdalnumeric.py build/lib.linux-x86_64-3.7/osgeo/gdalconst.py build/lib.linux-x86_64-3.7/osgeo/gdalnumeric.py build/lib.linux-x86_64-3.7/osgeo/osr.py build/lib.linux-x86_64-3.7/osgeo/gnm.py build/lib.linux-x86_64-3.7/osgeo/__init__.py build/lib.linux-x86_64-3.7/osgeo/ogr.py build/lib.linux-x86_64-3.7/osgeo/gdal.py build/lib.linux-x86_64-3.7/osgeo/gdal_array.py
 Skipping optional fixer: ws_comma
 Fixing build/lib.linux-x86_64-3.7/gdal.py build/lib.linux-x86_64-3.7/ogr.py build/lib.linux-x86_64-3.7/osr.py build/lib.linux-x86_64-3.7/gdalconst.py build/lib.linux-x86_64-3.7/gdalnumeric.py build/lib.linux-x86_64-3.7/osgeo/gdalconst.py build/lib.linux-x86_64-3.7/osgeo/gdalnumeric.py build/lib.linux-x86_64-3.7/osgeo/osr.py build/lib.linux-x86_64-3.7/osgeo/gnm.py build/lib.linux-x86_64-3.7/osgeo/__init__.py build/lib.linux-x86_64-3.7/osgeo/ogr.py build/lib.linux-x86_64-3.7/osgeo/gdal.py build/lib.linux-x86_64-3.7/osgeo/gdal_array.py
 Skipping optional fixer: ws_comma
 running build_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 -c gdal_python_cxx11_test.cpp -o gdal_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 -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o -std=c++11
 building 'osgeo._gdal' extension
 creating build/temp.linux-x86_64-3.7
 creating build/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 -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-3.7/extensions/gdal_wrap.o -std=c++11 -I/home/dennis/miniconda3/include
 cc1plus: warning: command line option ‘-Wstrict-prototypes' is valid for C/ObjC but not for C++
 extensions/gdal_wrap.cpp:4075:1: error: ‘VSIDIR' does not name a type
  VSIDIR* wrapper_VSIOpenDir( const char * utf8_path,
  ^
 extensions/gdal_wrap.cpp:4123:38: error: ‘VSIDIR' was not declared in this scope
  DirEntry* wrapper_VSIGetNextDirEntry(VSIDIR* dir)
           ^
 extensions/gdal_wrap.cpp:4123:46: error: ‘dir' was not declared in this scope
  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)' defined but not used [-Wunused-function]
  char* get_aligned_buffer(char* data, GDALDataType ntype)
   ^
 extensions/gdal_wrap.cpp:3244:13: warning: ‘void update_buffer_size(void*, char*, char*, size_t)' defined but not used [-Wunused-function]
  static void update_buffer_size(void* obj, char* data, char* data_aligned, size_t buf_size)
     ^
 extensions/gdal_wrap.cpp:3299:5: warning: ‘int GetUseExceptions()' defined but not used [-Wunused-function]
  int GetUseExceptions() {
   ^
 extensions/gdal_wrap.cpp:3305:6: warning: ‘void UseExceptions()' defined but not used [-Wunused-function]
  void UseExceptions() {
   ^
 extensions/gdal_wrap.cpp:3322:6: warning: ‘void DontUseExceptions()' defined but not used [-Wunused-function]
  void DontUseExceptions() {
   ^
 extensions/gdal_wrap.cpp:3370:13: warning: ‘void ClearErrorState()' defined but not used [-Wunused-function]
  static void ClearErrorState()
     ^
 error: command 'gcc' failed with exit status 1
 ----------------------------------------
ERROR: Command "/home/dennis/miniconda3/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-i321

总结

以上所述是小编给大家介绍的python安装gdal的两种方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对三水点靠木网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!

Python 相关文章推荐
python实现文件快照加密保护的方法
Jun 30 Python
Python3实现抓取javascript动态生成的html网页功能示例
Aug 22 Python
Python编程图形库之Pillow使用方法讲解
Dec 28 Python
python实现QQ批量登录功能
Jun 19 Python
详细介绍pandas的DataFrame的append方法使用
Jul 31 Python
对tensorflow 中tile函数的使用详解
Feb 07 Python
matlab中imadjust函数的作用及应用举例
Feb 27 Python
matplotlib jupyter notebook 图像可视化 plt show操作
Apr 24 Python
python如何实现DES加密
Sep 21 Python
python 基于Apscheduler实现定时任务
Dec 15 Python
十个Python自动化常用操作,即拿即用
May 10 Python
浅谈Python 中的复数问题
May 19 Python
pygame实现俄罗斯方块游戏(基础篇2)
Oct 29 #Python
pygame实现俄罗斯方块游戏(基础篇1)
Oct 29 #Python
pygame实现五子棋游戏
Oct 29 #Python
python多线程案例之多任务copy文件完整实例
Oct 29 #Python
jenkins配置python脚本定时任务过程图解
Oct 29 #Python
pygame实现成语填空游戏
Oct 29 #Python
Python多线程及其基本使用方法实例分析
Oct 29 #Python
You might like
PHP自动更新新闻DIY
2006/10/09 PHP
PHP 数组实例说明
2008/08/18 PHP
PHP生成二维码与识别二维码的方法详解【附源码下载】
2019/03/07 PHP
yii2 开发api接口时优雅的处理全局异常的方法
2019/05/14 PHP
iis6+javascript Add an Extension File
2007/06/13 Javascript
JavaScript在IE中“意外地调用了方法或属性访问”
2008/11/19 Javascript
JavaScript 全角转半角部分
2009/10/28 Javascript
jquery 应用代码 方便的排序功能
2010/02/06 Javascript
javascript 学习笔记(六)浏览器类型及版本信息检测代码
2011/04/08 Javascript
基于jquery的文章中所有图片width大小批量设置方法
2013/08/01 Javascript
深入理解javascript中defer的作用
2013/12/11 Javascript
js实现类似新浪微博首页内容渐显效果的方法
2015/04/10 Javascript
javascript实时获取鼠标坐标值并显示的方法
2015/04/30 Javascript
详解vue express启动数据服务
2017/07/05 Javascript
在Vant的基础上封装下拉日期控件的代码示例
2018/12/05 Javascript
vue中watch和computed为什么能监听到数据的改变以及不同之处
2019/12/27 Javascript
Vue 中 template 有且只能一个 root的原因解析(源码分析)
2020/04/11 Javascript
浅谈JavaScript窗体Window.ShowModalDialog使用
2020/07/22 Javascript
关于better-scroll插件的无法滑动bug(2021通过插件解决)
2021/03/01 Javascript
Python实现PS图像调整之对比度调整功能示例
2018/01/26 Python
利用Python读取txt文档的方法讲解
2018/06/23 Python
python实现点对点聊天程序
2018/07/28 Python
解决Python3.5+OpenCV3.2读取图像的问题
2018/12/05 Python
Python实现定制自动化业务流量报表周报功能【XlsxWriter模块】
2019/03/11 Python
Python 绘制酷炫的三维图步骤详解
2019/07/12 Python
python动态视频下载器的实现方法
2019/09/16 Python
python实现操作文件(文件夹)
2019/10/31 Python
Python3 用matplotlib绘制sigmoid函数的案例
2020/12/11 Python
基于 Python 实践感知器分类算法
2021/01/07 Python
浅谈cookie和localStorage那些事
2019/08/27 HTML / CSS
树转促学习心得体会
2014/09/10 职场文书
2014年小学德育工作总结
2014/12/05 职场文书
2015年客服工作总结范文
2015/04/02 职场文书
婚礼双方父亲致辞
2015/07/27 职场文书
导游词之杭州西湖
2019/09/19 职场文书
Mysql如何查看是否使用到索引
2022/12/24 MySQL