2

I am trying to install GDAL on an clean Anaconda environment (Python 3.7.11) but it fails when imported in the Python console. It does work fine in another environment (Python 3.6). GDAL package is from the main channel (3.0.2) for both (a simple conda install gdal). I can't figure out why it fails in 3.7. here is what it says: (can't find the module)

enter image description here

2
  • 1
    please don't post pictures of error messages
    – Ian Turton
    Feb 28, 2022 at 16:49
  • ok, I will keep it in mind Feb 28, 2022 at 16:55

2 Answers 2

3

Turns out I was trying to import gdal when now the correct way is to from osgeo import gdal or import osgeo.gdal as gdal Module instalation was ok.

0

Look at this code:

# Create a new environment

conda create -n gis python=3.7 anaconda

# Activate the environment

conda activate gis

# Install gdal

conda install -c conda-forge gdal
8
  • Installing the anaconda package and then the gdal module through conda-forge does work, but it installs a pretty old version of gdal (2.3.3) instead of version 3.4.1 Feb 28, 2022 at 16:39
  • 1
    I think, it is not possible to install a different version and you can have problems when you import modules. You should work with this version.
    – Helios
    Feb 28, 2022 at 16:46
  • Anaconda automatically finds the compatible version. You can try another version of python like 3.8 or 3.9 if you want to work with the latest versions.
    – Helios
    Feb 28, 2022 at 17:02
  • what does the "anaconda" command do in the conda create? installs all the anaconda tools? why doesn't it work simply installing the gdal package? Feb 28, 2022 at 17:17
  • Install all the necessary packages for your environment, also jupyter notebook or conda-pack, etc.
    – Helios
    Feb 28, 2022 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.