ImportError: DLL load failed while importing _gdal: The specified module could not be found

Question:

I have a python script that previously worked but that now throws the error:ImportError: DLL load failed while importing _gdal: The specified module could not be found. I am trying to upload a shapefile using fiona and originally the message read: ImportError: DLL load failed while importing _fiona: The specified module could not be found. I am using anaconda navigator as my IDE on windows 11.

I am aware that this is a question that has been asked before and I have read the answers to those questions. The solutions, however, hove not worked either due to my circumstance or my misinterpretation and action in following through with it. So my question is either how do I fix this, or, if it is not that simple, to better understand the problem.

I have looked inside the DLLs folder within the environment folder that I am using and there is nothing in there with name fiona, gdal or geopandas.

My attempts so far:

1. uninstall and re-install fiona gdal and geopandas (as I believe they are dependent).

2. update all libraries and anaconda to latest verions.

3. download Visual C++ Redistributable for Visual Studio 2015. Ran into issue during download as it was already installed on my computer, likely because it is a windows computer. Is it possible that this would help if i moved it to a different path/folder?

4. Uninstall and re-install anaconda navigator on cumputer. Re-create virtual environemt and import necessary libraries. result: error in line: import geopandas as gpd: ImportError: DLL load failed while importing _datadir: The specified module could not be found.

If there is a fix that I have not mentioned or if you suspect that I attempted one of the above fixed incorrectly because of my limited understanding of how python libraries are stored please make a suggestion!

Thank you

Asked By: Max Duso

||

Answers:

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 By: HM_ft

conda install gdal=3.0.2

This problem appears to be peculiar to newer versions of GDAL. The reason that HM_ft’s trick of downgrading Python to version 3.6 worked was that it also caused GDAL to be downgraded to version 3.0.2.

FWIW – GDAL versions 3.4.1 and 3.5.2 have this issue for me. I am not sure of which intervening version (after 3.0.2 and up to 3.4.1) marks the point at which this problem appears.

(added info) I have created a GDAL problem report on this issue: https://github.com/OSGeo/gdal/issues/6569

Answered By: Edward Schaefer
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.