pythonvirtualenvgdalogrosgeo

No module named 'ogr'


I followed this tutorial (https://gis.stackexchange.com/a/124420) to install gdal in a virtualenv. It seemed to work since I didn't get No module named 'osgeo' anymore when trying to import gdal.

But now I'm getting this error:

File "/home/user/.virtualenvs/my-venv/lib/python3.5/site-packages/osgeo/gdal.py",
line 1468, in <module>
    import ogr
ImportError: No module named 'ogr'

I checked this directory, and it have the ogr.py file along with the gdal.py file.

Anyone know how to fix this? I'm almost trying to install it all again (not an easy task)

EDIT: In a shell inside my venv, I can do from osgeo import ogr but when I try from osgeo import gdal it gives the same error, when gdal try to import ogr, this means they are both in the osgeo module, but gdal can't "see" ogr for some reason I can't figure out


Solution

  • I uninstalled "pygdal" and did it manually as this answer says. Downloading "gdal" via pip download gdal and running python setup.py install --install-headers=<path/to/gdal_headers>