0

I'm trying to install GDAL osgeo lib into Python 3.6 on Debian Stretch

I installed neccessary packages like:

sudo apt-get update && sudo apt-get install -y \
  binutils \
  libproj-dev \
  gdal-bin \
  libgdal-dev \
  python3-gdal \
  python3-pip \
  python-numpy \
  python-dev \

That installation works for Python 2.7 and Python <= 3.5.

But in interpreter I'm receiving following error:

>>> import osgeo
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'osgeo'

Do you know any solution for fixing that?

1
  1. Try locating the directory where your gdal python bindings are installed (e.g., search for osgeo.py).
  2. Add that path to your python's sys.path, which can be done by editing the .pth file under your python's sitepackage folder. I suggest simply inserting that directory to sys.path first to see whether it works.

I did this on Mac OS and it worked for python 3.6.

1

I solved this problem by installing via Python PIP pygdal package. Firstly you need to check Gdal version installed on the machine, and install proper pygdal.

$ gdalinfo --version
GDAL 2.1.3, released 2017/20/01
$ pip install "pygdal>=2.1.2,<2.1.3"
  • 1
    I think it should read 'pip install "pygdal>=2.1.2,<2.1.3"'. This work for me, thanks! – StephenT Jun 10 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.