「pip install GDAL==3.1.3」などのコマンドでインストールするとうまくいかない場合があります。
これはインストール時にビルドを行っていて、環境によって依存しているライブラリなどが不足しているためです。
※エラーは下部に掲載しています。
こういった場合はwhlを使うことでインストールすることができます。
手順
インストールされているGDALと同じバージョンをインストールする必要があるのでGDALのバージョンを確認しておきます。
gdalinfo --version GDAL 3.1.3, released 2020/09/01
つぎに下記のサイトからインストールしたいGDALのwhlファイルをダウンロードします。
>>lfd.uci.edu/~gohlke/pythonlibs/#gdal
Pythonは3.6を使用しているため下記をダウンロードしました。
GDAL-3.1.3-cp36-cp36m-win_amd64.whl
インストールコマンド「pip install .\GDAL-3.1.3-cp36-cp36m-win_amd64.whl」を実行してみます。
pip install .\GDAL-3.1.3-cp36-cp36m-win_amd64.whl Processing c:\work\gdal-3.1.3-cp36-cp36m-win_amd64.whl Installing collected packages: GDAL Successfully installed GDAL-3.1.3
うまくインストールできました。
続いて簡単な動作確認用のプログラムを実行してみます。
画像のサイズとバンド数が出力されてばOKです。
#!/usr/bin/env python # -*- coding: utf-8 -*- import numpy as np from osgeo import gdal, gdalconst ds = gdal.Open('./image.tif', gdalconst.GA_ReadOnly) print(ds.RasterXSize) print(ds.RasterYSize) print(ds.RasterCount)出力結果サンプル
12742 17879 4
インストール時のエラー例1
pip install GDAL==2.4.4 Collecting GDAL==2.4.4 Using cached GDAL-2.4.4.tar.gz (564 kB) Using legacy 'setup.py install' for GDAL, since package 'wheel' is not installed. Installing collected packages: GDAL Running setup.py install for GDAL ... error ERROR: Command errored out with exit status 1: command: 'c:\users\Administrator\appdata\local\programs\python\python36\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-9hihw37x\\gdal\\setup.py'"'"'; __file__='"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-9hihw37x\\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\Administrator\AppData\Local\Temp\pip-record-3dvhsmht\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\Administrator\appdata\local\programs\python\python36\Include\GDAL' cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-9hihw37x\gdal\ Complete output (28 lines): running install running build running build_py creating build creating build\lib.win-amd64-3.6 copying gdal.py -> build\lib.win-amd64-3.6 copying ogr.py -> build\lib.win-amd64-3.6 copying osr.py -> build\lib.win-amd64-3.6 copying gdalconst.py -> build\lib.win-amd64-3.6 copying gdalnumeric.py -> build\lib.win-amd64-3.6 creating build\lib.win-amd64-3.6\osgeo copying osgeo\gdal.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\gdalconst.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\gdalnumeric.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\gdal_array.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\gnm.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\ogr.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\osr.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\__init__.py -> build\lib.win-amd64-3.6\osgeo c:\users\Administrator\appdata\local\programs\python\python36\lib\site-packages\setuptools\lib2to3_ex.py:41: SetuptoolsDeprecationWarning: 2to3 support is deprecated. If the project still requires Python 2 support, please migrate to a single-codebase solution or employ an independent conversion process. SetuptoolsDeprecationWarning) 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 Skipping optional fixer: ws_comma 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 Skipping optional fixer: ws_comma running build_ext building 'osgeo._gdal' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ ---------------------------------------- ERROR: Command errored out with exit status 1: 'c:\users\Administrator\appdata\local\programs\python\python36\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-9hihw37x\\gdal\\setup.py'"'"'; __file__='"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-9hihw37x\\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\Administrator\AppData\Local\Temp\pip-record-3dvhsmht\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\Administrator\appdata\local\programs\python\python36\Include\GDAL' Check the logs for full command output.
インストール時のエラー例2
pip install GDAL==3.1.3 Collecting GDAL==3.1.3 Downloading GDAL-3.1.3.tar.gz (593 kB) |████████████████████████████████| 593 kB 6.4 MB/s Using legacy 'setup.py install' for GDAL, since package 'wheel' is not installed. Installing collected packages: GDAL Running setup.py install for GDAL ... error ERROR: Command errored out with exit status 1: command: 'c:\users\Administrator\appdata\local\programs\python\python36\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-nuxie4dc\\gdal\\setup.py'"'"'; __file__='"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-nuxie4dc\\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\Administrator\AppData\Local\Temp\pip-record-62ern880\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\Administrator\appdata\local\programs\python\python36\Include\GDAL' cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-nuxie4dc\gdal\ Complete output (63 lines): running install running build running build_py creating build creating build\lib.win-amd64-3.6 copying gdal.py -> build\lib.win-amd64-3.6 copying ogr.py -> build\lib.win-amd64-3.6 copying osr.py -> build\lib.win-amd64-3.6 copying gdalconst.py -> build\lib.win-amd64-3.6 copying gdalnumeric.py -> build\lib.win-amd64-3.6 creating build\lib.win-amd64-3.6\osgeo copying osgeo\gdal.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\gdalconst.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\gdalnumeric.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\gdal_array.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\gnm.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\ogr.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\osr.py -> build\lib.win-amd64-3.6\osgeo copying osgeo\__init__.py -> build\lib.win-amd64-3.6\osgeo c:\users\Administrator\appdata\local\programs\python\python36\lib\site-packages\setuptools\lib2to3_ex.py:41: SetuptoolsDeprecationWarning: 2to3 support is deprecated. If the project still requires Python 2 support, please migrate to a single-codebase solution or employ an independent conversion process. SetuptoolsDeprecationWarning) 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 Skipping optional fixer: ws_comma 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 Skipping optional fixer: ws_comma running build_ext building 'osgeo._gdal' extension building 'osgeo._gdalconst' extension building 'osgeo._osr' extension building 'osgeo._ogr' extension creating build\temp.win-amd64-3.6 creating build\temp.win-amd64-3.6 creating build\temp.win-amd64-3.6 creating build\temp.win-amd64-3.6 creating build\temp.win-amd64-3.6\Release creating build\temp.win-amd64-3.6\Release creating build\temp.win-amd64-3.6\Release creating build\temp.win-amd64-3.6\Release creating build\temp.win-amd64-3.6\Release\extensions creating build\temp.win-amd64-3.6\Release\extensions creating build\temp.win-amd64-3.6\Release\extensions creating build\temp.win-amd64-3.6\Release\extensions C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\bin\HostX86\x64\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 -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpextensions/gdal_wrap.cpp /Fobuild\temp.win-amd64-3.6\Release\extensions/gdal_wrap.obj C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\bin\HostX86\x64\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 -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tcextensions/gdalconst_wrap.c /Fobuild\temp.win-amd64-3.6\Release\extensions/gdalconst_wrap.obj C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\bin\HostX86\x64\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 -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpextensions/ogr_wrap.cpp /Fobuild\temp.win-amd64-3.6\Release\extensions/ogr_wrap.obj C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\bin\HostX86\x64\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 -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpextensions/osr_wrap.cpp /Fobuild\temp.win-amd64-3.6\Release\extensions/osr_wrap.obj gdal_wrap.cpp osr_wrap.cpp gdalconst_wrap.c ogr_wrap.cpp extensions/gdalconst_wrap.c(3018): fatal error C1083: include ファイルを開けません。'gdal.h':No such file or directory extensions/osr_wrap.cpp(3198): fatal error C1083: include ファイルを開けません。'cpl_string.h':No such file or directory extensions/ogr_wrap.cpp(3149): fatal error C1083: include ファイルを開けません。'gdal.h':No such file or directoryextensions/gdal_wrap.cpp(3189): fatal error C1083: include ファイルを開けません。'cpl_port.h':No such file or directory building 'osgeo._gnm' extension C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\bin\HostX86\x64\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 -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpextensions/gnm_wrap.cpp /Fobuild\temp.win-amd64-3.6\Release\extensions/gnm_wrap.obj gnm_wrap.cpp extensions/gnm_wrap.cpp(3135): fatal error C1083: include ファイルを開けません。'gdal.h':No such file or directory building 'osgeo._gdal_array' extension C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\bin\HostX86\x64\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 -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\include -Ic:\users\Administrator\appdata\local\programs\python\python36\lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /EHsc /Tpextensions/gdal_array_wrap.cpp /Fobuild\temp.win-amd64-3.6\Release\extensions/gdal_array_wrap.obj gdal_array_wrap.cpp extensions/gdal_array_wrap.cpp(3144): fatal error C1083: include ファイルを開けません。'gdal.h':No such file or directory error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2 ---------------------------------------- ERROR: Command errored out with exit status 1: 'c:\users\Administrator\appdata\local\programs\python\python36\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-nuxie4dc\\gdal\\setup.py'"'"'; __file__='"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-nuxie4dc\\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\Administrator\AppData\Local\Temp\pip-record-62ern880\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\Administrator\appdata\local\programs\python\python36\Include\GDAL' Check the logs for full command output.
どうしてもうまく行かない時
どうしてもうまく行かない場合、GDALをインストールせずにGDALを使う方法もあるので、下記の記事も参考にしてみてください。
【簡単】GDALインストールせずにGDALを使う方法
gdalのインストールがうまく行かずに悩んでいるあなたに朗報です。
gdalのdockerコンテナを使うとgdalをインストールせずに使用することが可能です。