Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install GDAL in python 3.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

like image 821
Mar Avatar asked Jul 06 '18 21:07

Mar


2 Answers

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.

like image 98
johnny Avatar answered Oct 19 '22 07:10

johnny


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
like image 36
Ioannis Nasios Avatar answered Oct 19 '22 08:10

Ioannis Nasios