Search code examples
pythonjupyter-notebookgdal

gdal not installed - Error in jupyterlab notebook but not in command line


I have been trying to install gdal on jupyter notebook but it is giving error that module not found but from command prompt if I activate the same environment it shows what is expected.

I am using python version 3.7 and windows 10. I installed gdal from conda as well as from jupyter notebook but same error.

enter image description here

enter image description here


Solution

  • The current convention to import gdal is

    from osgeo import gdal
    

    If that doesn't work then you are missing the python bindings for gdal. If you have indeed a working gdal installation, try to install the python bindings with pip:

    pip install gdal==$(gdal-config --version)
    

    at which point you should be able to import gdal in python.