python-3.xwindowsgdal

Issues with installing GDAL for Python 3.7.3 on Windows


I am having trouble trying to install GDAL using Python 3.7.3 on Windows.

Does anyone out there have any experience installing this?

pip install GDAL
    Collecting GDAL
      Using cached https://files.pythonhosted.org/packages/ae/09/cac5021db34f5c95c6a660b90e5d27062a520fe32a0493f68d07a7055d30/GDAL-3.0.4.tar.gz
    Building wheels for collected packages: GDAL
      Building wheel for GDAL (setup.py) ... error
      ERROR: Complete output from command 'C:\Users\Farhan\Anaconda3\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\Farhan\\AppData\\Local\\Temp\\pip-install-bwqvn3wb\\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\Farhan\AppData\Local\Temp\pip-wheel-0gdpm9_l' --python-tag cp37:
      ERROR: running bdist_wheel
      
        error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
        ----------------------------------------
    ERROR: Command "'C:\Users\Farhan\Anaconda3\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\Farhan\\AppData\\Local\\Temp\\pip-install-bwqvn3wb\\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\Farhan\AppData\Local\Temp\pip-record-yg5kb88q\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Farhan\AppData\Local\Temp\pip-install-bwqvn3wb\GDAL\

Solution

  • Chris Gohlke has a fantastic repository of pre-built python wheels for windows, amongst them GDAL.

    So depending on the GDAL version desired, the python version used and your system (win_amd64?) you can just download the corresponding wheel file and install it locally using pip.


    E.g. to install GDAL 3.0.4, running under python3.7 on a 64bit machine, you need to download:

    GDAL‑3.0.4‑cp37‑cp37m‑win_amd64.whl

    and install it

    pip3 install C:\Users\foo\bar\GDAL‑3.0.4‑cp37‑cp37m‑win_amd64.whl

    Sidenote:

    For installing modules, especially complex like gdal, it always pays off to use a virtual environment, as provided by e.g. virtualenv.