I have installed GDAL and checked on the command line, it is working and when I run the gdal2tiles.py on the command line it works but when I run the same file gdal2tiles.py with python IDLE, I get "No module named 'osgeo'" error. Can you assist.


This sounds like you have multiple python installations, and GDAL is installed on one and not the other.

Try the following (which I have based upon this). Create a text file within your python installation site packages folder C:\Python27\Lib\site-packages called usrlocal.pth. In this text file insert one line giving the path to your second python installation site packages folder which features the GDAL install, for example:

  • I have done the above but now getting different error and also noticed what you mention above regarding two python (27 and 34) – Asanda Jan 31 '17 at 6:27
  • I removed the second python but still not working... – Asanda Jan 31 '17 at 7:50

Try this,

pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`    
  • It works well in my Mac with Python 3.8.3 (default, Jul 2 2020, 11:26:31) Anaconda. Successfully installed GDAL-3.2.0 – Hua Zhang Nov 19 '20 at 0:18
  • @Saroj, would appreciate it if you could explain why this works as it does or point to an explanation somewhere? – a different ben Nov 19 '20 at 2:24

Got the same problem. I fixed ir by installing python-gdal using synaptic with my Debian Jessie

  • 2
    Ok, but this question is for Windows OS (check tag osgeo4w). Your answer solves the problem in this OS? – aldo_tapia Sep 6 '17 at 19:35

Another possibility is using easy_install from Python:

easy_install gdal

Preferably install numpy for array operations first:

easy_install numpy

For more information about easy_install/setup tools: https://setuptools.readthedocs.io/en/latest/easy_install.html


I was struggling with this as well. Finally, I created a new virtualenv using Anaconda following this: How to Install PyTorch on Windows Step by Step.

Next, I just used anaconda prompt to install GDAL, i.e. typed: conda install GDAL. It worked! Pycharm recognises OSGeo now.

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.