6

i use python 3.6 32bit on os windows 32bit and i try to install GDAL package using first this manual but without success and after via pip error again.

from osgeo import gdal

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    from osgeo import gdal
  File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\site-packages\osgeo\__init__.py", line 41, in <module>
    _gdal = swig_import_helper()
  File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\site-packages\osgeo\__init__.py", line 37, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
  File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\username\AppData\Local\Programs\Python\Python36-32\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

install GDAL via PIP :

pip install GDAL 

error message :

6\osgeo\gdal_array.py build\lib.win32-3.6\osgeo\gnm.py build\lib.win32-3.6\osgeo
\ogr.py build\lib.win32-3.6\osgeo\osr.py build\lib.win32-3.6\osgeo\__init__.py
    Skipping optional fixer: ws_comma
    Fixing build\lib.win32-3.6\gdal.py build\lib.win32-3.6\ogr.py build\lib.win3
2-3.6\osr.py build\lib.win32-3.6\gdalconst.py build\lib.win32-3.6\gnm.py build\l
ib.win32-3.6\gdalnumeric.py build\lib.win32-3.6\osgeo\gdal.py build\lib.win32-3.
6\osgeo\gdalconst.py build\lib.win32-3.6\osgeo\gdalnumeric.py build\lib.win32-3.
6\osgeo\gdal_array.py build\lib.win32-3.6\osgeo\gnm.py build\lib.win32-3.6\osgeo
\ogr.py build\lib.win32-3.6\osgeo\osr.py build\lib.win32-3.6\osgeo\__init__.py
    Skipping optional fixer: ws_comma
    running build_ext
    building 'osgeo._gdal' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

    ----------------------------------------
Command "c:\users\username\appdata\local\programs\python\python36-32\python.exe -u
-c "import setuptools, tokenize;__file__='C:\\Users\\username\\AppData\\Local\\Temp
\\pip-install-t7el4b6x\\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\username\AppData\Local\Temp\pip-record-r_yx0388\
install-record.txt --single-version-externally-managed --compile" failed with er

that is bug for python 3.6 ? i dont want to use way via conda thank you

Mar
  • 683
  • 2
  • 11
  • 26
  • Try downloading an unofficial built wheel [here](https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal) ... this will save you from building GDAL on windows, which is always tricky. – Val Jul 09 '18 at 07:16

3 Answers3

6

This did the trick for me.

  1. Download GDAL-2.2.4-cp36-cp36m-win32.whl wheel from here
  2. Install it with pip install path/to/the/above/wheel/file

That is it. You can now import GDAL in your python code.

Azat Ibrakov
  • 9,998
  • 9
  • 38
  • 50
johnny
  • 2,032
  • 1
  • 25
  • 45
5

You have to install python version equal to installed gdal version.

First check install gdal version:

gdalinfo --version

For me gal installed version is

# GDAL 2.4.0, released 2018/12/14

Then install python package as:

pip install -I GDAL==2.4.0
Ioannis Nasios
  • 8,292
  • 4
  • 33
  • 55
0

You could also use conda to do the full installation :

conda install -c conda-forge gdal

You will install gdal from scractch (work on windows and linux)

Adrien Forbu
  • 483
  • 4
  • 18