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.
6 Answers
Try this,
pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`
- 259
- 3
- 6
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:
C:\OSGeo4W\apps\Python27\Lib\site-packages
-
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 06:27
-
-
Got the same problem. I fixed ir by installing python-gdal using synaptic with my Debian Jessie
- 29
- 2
-
2Ok, but this question is for Windows OS (check tag osgeo4w). Your answer solves the problem in this OS? – aldo_tapia Sep 06 '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
- 11
- 1
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.
- 76,800
- 56
- 247
- 389
- 1
For GDAL 3.7.1 built from source using CMake on Ubuntu 20.04, the following worked for me using Python 3.8.10.
sudo apt-get install python3-gdal
I was then able to do from osgeo import gdal for my application.
- 1
- 1
Successfully installed GDAL-3.2.0 – Hua Zhang Nov 19 '20 at 00:18
sudo apt install libgdal-devfirst. – khaverim Aug 25 '21 at 14:53