2

I am trying to run gdal in python using a script like this:

import os
gdal_path = r'"C:/Program Files/QGIS 3.22.1/apps/Python39/Scripts"'
gdal_calc_path = os.path.join(gdal_path, 'gdal_calc.py')
#commands come after

However, I am getting the error ```ImportError: DLL load failed while importing _gdal: The specified module could not be found.

On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH.
If gdalXXX.dll is in the PATH, then set the USE_PATH_FOR_GDAL_PYTHON=YES environment variable
to feed the PATH into os.add_dll_directory().

what does this mean?

asked Dec 1, 2021 at 11:38

2 Answers 2

0

I was struggling badly with the same problem for the last couple of days. Using conda, I've tried everything I found on the internet such as:

conda update gdal 
conda update -n base -c defaults conda

Creating new environments (over and over again).

Despite it's not recommended I even tried it with pip install... but no results.

At the end what worked for me was to create a new environment with Python version 3.6

conda create -n env python=3.6 gdal spyder 

Let me know if it worked.

answered Mar 8, 2022 at 15:12
-1

Install anaconda or miniconda

making a new enviroment

for example:

conda create --name name_env python=3.8 anaconda

then install packages

conda install -c conda-forge gdal, rasterio, geopandas

answered Dec 25, 2021 at 16:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.