当前位置:   article > 正文

用pip安装GDAL时出错解决办法_failed building wheel for gdal

failed building wheel for gdal

用pip安装gdal会报错:

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

 错误代码如下:

原因:GDAL不是纯净的python库,无法像pip install requests这样安装库文件。

  1. Building wheel for gdal (setup.py) ... error
  2. ERROR: Command errored out with exit status 1:
  3. command: 'd:\program\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\PC-CYQ\\AppData\\Local\\Temp\\pip-install-n61e5cwp\\gdal\\setup.py'"'"'; __file__='"'"'C:\\Users\\PC-CYQ\\AppData\\Local\\Temp\\pip-install-n61e5cwp\\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 'C:\Users\PC-CYQ\AppData\Local\Temp\pip-wheel-b1i402a_'
  4. cwd: C:\Users\PC-CYQ\AppData\Local\Temp\pip-install-n61e5cwp\gdal\
  5. Complete output (32 lines):
  6. running bdist_wheel
  7. running build
  8. running build_py
  9. creating build
  10. creating build\lib.win-amd64-3.6
  11. copying gdal.py -> build\lib.win-amd64-3.6
  12. copying ogr.py -> build\lib.win-amd64-3.6
  13. copying osr.py -> build\lib.win-amd64-3.6
  14. copying gdalconst.py -> build\lib.win-amd64-3.6
  15. copying gdalnumeric.py -> build\lib.win-amd64-3.6
  16. creating build\lib.win-amd64-3.6\osgeo
  17. copying osgeo\gdal.py -> build\lib.win-amd64-3.6\osgeo
  18. copying osgeo\gdalconst.py -> build\lib.win-amd64-3.6\osgeo
  19. copying osgeo\gdalnumeric.py -> build\lib.win-amd64-3.6\osgeo
  20. copying osgeo\gdal_array.py -> build\lib.win-amd64-3.6\osgeo
  21. copying osgeo\gnm.py -> build\lib.win-amd64-3.6\osgeo
  22. copying osgeo\ogr.py -> build\lib.win-amd64-3.6\osgeo
  23. copying osgeo\osr.py -> build\lib.win-amd64-3.6\osgeo
  24. copying osgeo\__init__.py -> build\lib.win-amd64-3.6\osgeo
  25. Fixing build\lib.win-amd64-3.6\gdal.py build\lib.win-amd64-3.6\ogr.py build\lib.win-amd64-3.6\osr.py build\lib.win-amd64-3.6\gdalconst.py build\lib.win-amd64-3.6\gdalnumeric.py build\lib.win-amd64-3.6\osgeo\gdal.py build\lib.win-amd64-3.6\osgeo\gdalconst.py build\lib.win-amd64-3.6\osgeo\gdalnumeric.py build\lib.win-amd64-3.6\osgeo\gdal_array.py build\lib.win-amd64-3.6\osgeo\gnm.py build\lib.win-amd64-3.6\osgeo\ogr.py build\lib.win-amd64-3.6\osgeo\osr.py build\lib.win-amd64-3.6\osgeo\__init__.py
  26. Skipping optional fixer: ws_comma
  27. Fixing build\lib.win-amd64-3.6\gdal.py build\lib.win-amd64-3.6\ogr.py build\lib.win-amd64-3.6\osr.py build\lib.win-amd64-3.6\gdalconst.py build\lib.win-amd64-3.6\gdalnumeric.py build\lib.win-amd64-3.6\osgeo\gdal.py build\lib.win-amd64-3.6\osgeo\gdalconst.py build\lib.win-amd64-3.6\osgeo\gdalnumeric.py build\lib.win-amd64-3.6\osgeo\gdal_array.py build\lib.win-amd64-3.6\osgeo\gnm.py build\lib.win-amd64-3.6\osgeo\ogr.py build\lib.win-amd64-3.6\osgeo\osr.py build\lib.win-amd64-3.6\osgeo\__init__.py
  28. Skipping optional fixer: ws_comma
  29. running build_ext
  30. building 'osgeo._gdal' extension
  31. creating build\temp.win-amd64-3.6
  32. creating build\temp.win-amd64-3.6\Release
  33. creating build\temp.win-amd64-3.6\Release\extensions
  34. C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -Id:\program\anaconda3\include -Id:\program\anaconda3\include -Id:\program\anaconda3\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tpextensions/gdal_wrap.cpp /Fobuild\temp.win-amd64-3.6\Release\extensions/gdal_wrap.obj
  35. gdal_wrap.cpp
  36. extensions/gdal_wrap.cpp(3173): fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory
  37. error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
  38. ----------------------------------------
  39. ERROR: Failed building wheel for gdal
  40. Running setup.py clean for gdal
  41. Failed to build gdal
  42. Installing collected packages: gdal
  43. Running setup.py install for gdal ... error
  44. ERROR: Command errored out with exit status 1:
  45. command: 'd:\program\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\PC-CYQ\\AppData\\Local\\Temp\\pip-install-n61e5cwp\\gdal\\setup.py'"'"'; __file__='"'"'C:\\Users\\PC-CYQ\\AppData\\Local\\Temp\\pip-install-n61e5cwp\\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 'C:\Users\PC-CYQ\AppData\Local\Temp\pip-record-rqe9ylsx\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\program\anaconda3\Include\gdal'
  46. cwd: C:\Users\PC-CYQ\AppData\Local\Temp\pip-install-n61e5cwp\gdal\
  47. Complete output (32 lines):
  48. running install
  49. running build
  50. running build_py
  51. creating build
  52. creating build\lib.win-amd64-3.6
  53. copying gdal.py -> build\lib.win-amd64-3.6
  54. copying ogr.py -> build\lib.win-amd64-3.6
  55. copying osr.py -> build\lib.win-amd64-3.6
  56. copying gdalconst.py -> build\lib.win-amd64-3.6
  57. copying gdalnumeric.py -> build\lib.win-amd64-3.6
  58. creating build\lib.win-amd64-3.6\osgeo
  59. copying osgeo\gdal.py -> build\lib.win-amd64-3.6\osgeo
  60. copying osgeo\gdalconst.py -> build\lib.win-amd64-3.6\osgeo
  61. copying osgeo\gdalnumeric.py -> build\lib.win-amd64-3.6\osgeo
  62. copying osgeo\gdal_array.py -> build\lib.win-amd64-3.6\osgeo
  63. copying osgeo\gnm.py -> build\lib.win-amd64-3.6\osgeo
  64. copying osgeo\ogr.py -> build\lib.win-amd64-3.6\osgeo
  65. copying osgeo\osr.py -> build\lib.win-amd64-3.6\osgeo
  66. copying osgeo\__init__.py -> build\lib.win-amd64-3.6\osgeo
  67. Fixing build\lib.win-amd64-3.6\gdal.py build\lib.win-amd64-3.6\ogr.py build\lib.win-amd64-3.6\osr.py build\lib.win-amd64-3.6\gdalconst.py build\lib.win-amd64-3.6\gdalnumeric.py build\lib.win-amd64-3.6\osgeo\gdal.py build\lib.win-amd64-3.6\osgeo\gdalconst.py build\lib.win-amd64-3.6\osgeo\gdalnumeric.py build\lib.win-amd64-3.6\osgeo\gdal_array.py build\lib.win-amd64-3.6\osgeo\gnm.py build\lib.win-amd64-3.6\osgeo\ogr.py build\lib.win-amd64-3.6\osgeo\osr.py build\lib.win-amd64-3.6\osgeo\__init__.py
  68. Skipping optional fixer: ws_comma
  69. Fixing build\lib.win-amd64-3.6\gdal.py build\lib.win-amd64-3.6\ogr.py build\lib.win-amd64-3.6\osr.py build\lib.win-amd64-3.6\gdalconst.py build\lib.win-amd64-3.6\gdalnumeric.py build\lib.win-amd64-3.6\osgeo\gdal.py build\lib.win-amd64-3.6\osgeo\gdalconst.py build\lib.win-amd64-3.6\osgeo\gdalnumeric.py build\lib.win-amd64-3.6\osgeo\gdal_array.py build\lib.win-amd64-3.6\osgeo\gnm.py build\lib.win-amd64-3.6\osgeo\ogr.py build\lib.win-amd64-3.6\osgeo\osr.py build\lib.win-amd64-3.6\osgeo\__init__.py
  70. Skipping optional fixer: ws_comma
  71. running build_ext
  72. building 'osgeo._gdal' extension
  73. creating build\temp.win-amd64-3.6
  74. creating build\temp.win-amd64-3.6\Release
  75. creating build\temp.win-amd64-3.6\Release\extensions
  76. C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -Id:\program\anaconda3\include -Id:\program\anaconda3\include -Id:\program\anaconda3\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /EHsc /Tpextensions/gdal_wrap.cpp /Fobuild\temp.win-amd64-3.6\Release\extensions/gdal_wrap.obj
  77. gdal_wrap.cpp
  78. extensions/gdal_wrap.cpp(3173): fatal error C1083: Cannot open include file: 'cpl_port.h': No such file or directory
  79. error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
  80. ----------------------------------------
  81. ERROR: Command errored out with exit status 1: 'd:\program\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\PC-CYQ\\AppData\\Local\\Temp\\pip-install-n61e5cwp\\gdal\\setup.py'"'"'; __file__='"'"'C:\\Users\\PC-CYQ\\AppData\\Local\\Temp\\pip-install-n61e5cwp\\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 'C:\Users\PC-CYQ\AppData\Local\Temp\pip-record-rqe9ylsx\install-record.txt' --single-version-externally-managed --compile --install-headers 'd:\program\anaconda3\Include\gdal' Check the logs for full command output.

解决办法: 

根据自己的python版本,下载对应的GDAL安装文件

1.官网下载,下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal 

可能下载缓慢,或下载失败

2.网盘下载:

GDAL-2.2.4-cp36-cp36m-win_amd64.whlGDAL-2.2.4-cp37-cp37m-win_amd64.whl:

https://pan.baidu.com/s/1yyz4eERmZgzAwTZryrI1dA 密码: 468c

GDAL-2.2.4-cp27-cp27m-win_amd64.whl:

https://pan.baidu.com/s/1Yfj4tcgJ2iSxqEc3XC39Hw 密码:9hrj

安装:

pip install GDAL-2.2.4-cp36-cp36m-win_amd64.whl

 

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号