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快速从注释生成文档的方法
Dec 26 Python
python根据unicode判断语言类型实例代码
Jan 17 Python
解决Python运行文件出现out of memory框的问题
Dec 03 Python
selenium2.0中常用的python函数汇总
Aug 05 Python
python__name__原理及用法详解
Nov 02 Python
Python3查找列表中重复元素的个数的3种方法详解
Feb 13 Python
python能在浏览器能运行吗
Jun 17 Python
python 怎样进行内存管理
Nov 10 Python
Flask-SocketIO服务端安装及使用代码示例
Nov 26 Python
pandas针对excel处理的实现
Jan 15 Python
python中time.ctime()实例用法
Feb 03 Python
Python OpenCV实现图形检测示例详解
Apr 08 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中进行身份认证
2006/10/09 PHP
Windows下的PHP安装pear教程
2014/10/24 PHP
ecshop后台编辑器替换成ueditor编辑器
2015/03/03 PHP
PHP之正则表达式捕获组与非捕获组(详解)
2015/07/29 PHP
PHP工程师VIM配置分享
2015/12/15 PHP
JavaScript 节点操作 以及DOMDocument属性和方法
2007/12/06 Javascript
加载jQuery后$冲突的解决办法
2010/07/09 Javascript
js的一些常用方法小结
2011/06/29 Javascript
js字符串转换成xml对象并使用技巧解读
2013/04/18 Javascript
jQuery焦点图切换特效插件封装实例
2013/08/18 Javascript
利用cookie记住背景颜色示例代码
2013/11/04 Javascript
Node.js 的异步 IO 性能探讨
2014/10/08 Javascript
JQuery中extend的用法实例分析
2015/02/08 Javascript
JS或jQuery获取ASP.NET服务器控件ID的方法
2015/06/08 Javascript
JS实现可编辑的后台管理菜单功能【附demo源码下载】
2016/09/13 Javascript
JS实现图片放大镜插件详解
2017/11/06 Javascript
js 实现在2d平面上画8的方法
2018/10/10 Javascript
解决layui批量传值到后台操作时出现传值为空的问题
2019/09/28 Javascript
微信小程序中weui用法解析
2019/10/21 Javascript
js中关于Blob对象的介绍与使用
2019/11/29 Javascript
Javascript异步编程async实现过程详解
2020/04/02 Javascript
vue中解决微信html5原生ios虚拟键返回不刷新问题
2020/10/20 Javascript
[45:15]Optic vs VP 2018国际邀请赛淘汰赛BO3 第一场 8.24
2018/08/25 DOTA
numpy中的delete删除数组整行和整列的实例
2018/05/09 Python
Django渲染Markdown文章目录的方法示例
2019/01/02 Python
Python实现简单的列表冒泡排序和反转列表操作示例
2019/07/10 Python
Python 等分切分数据及规则命名的实例代码
2019/08/16 Python
如何验证python安装成功
2020/07/06 Python
利用Python如何画一颗心、小人发射爱心
2021/02/21 Python
python中if嵌套命令实例讲解
2021/02/25 Python
viagogo法国票务平台:演唱会、体育比赛、戏剧门票
2017/03/27 全球购物
《要下雨了》教学反思
2014/02/17 职场文书
2014年作风建设心得体会
2014/10/22 职场文书
运动会100米广播稿
2015/08/19 职场文书
为什么 Nginx 比 Apache 更牛逼
2021/03/31 Servers
JavaScript展开运算符和剩余运算符的区别详解
2022/02/18 Javascript