2

As I am working in ubuntu. This works if I deactivate the virtual environment but after activating the environment I got the error saying no module named osgeo.

How do I install it?

from osgeo import ogr, osr
PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Saroj Rai
  • 259
  • 3
  • 6

1 Answers1

2

As I am able to solve this by installing libgdal-dev and pygdal (Virtualenv and setuptools friendly version of standard GDAL python bindings.)

sudo apt-get install libgdal-dev

In case not installed, install using aptitude

sudo aptitude install libgdal-dev

After that check GDAL version of your system,

gdalinfo --version

lets say you have GDAL version as

GDAL 2.2.3, released 2017/11/20

Then install pygdal of same version of GDAL

pip install pygdal==2.2.3.3

Also I am able to install with single command

pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`    
Saroj Rai
  • 259
  • 3
  • 6