Reputation: 409
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
Upvotes: 5
Views: 14475
Reputation: 1
I got the same error message when i tried to import gdal 3.4.3 with the following command:
from osgeo import gdal
ImportError: DLL load failed while importing _gdal: The specified procedure could not be found.
I installed gdal 3.4.3 into a fresh conda environment on Windows 10.
The error could be resolved by an update of the Microsoft Visual C++ 2015-2019 Redistributable from 14.28.29914 to 14.34.33130. The idea was hinted by the answer from E_Cross who did not have the redistributable at all. Also I reinstalled gdal into a new environment after the update of the redistributable.
Upvotes: 0
Reputation: 33
I was also receiving the ImportError: DLL load failed while importing _gdal: The specified module could not be found.
message. However, it turns out that the problem was not the absence of the GDAL DLL itself, but the absence of one of its dependencies. I supplied this dependency by installing the Visual Studio redistributable.
The error message is misleading, or at least confusing, in that it's not obvious that "the specified module" may refer to a dependency of the library that Python is trying to import. It seems that the ambiguity is not the fault of the Python implementation, however, but goes back to the Windows API.
Upvotes: 0
Reputation: 57
Try this sequence -
pip install wheel
pip install pipwin
pipwin install numpy
pipwin install pandas
pipwin install shapely
pipwin install gdal
pipwin install fiona
pipwin install pyproj
pipwin install six
pipwin install rtree
pipwin install geopandas
Source - https://stackoverflow.com/a/58943939/14111919
After this, try
pip install rasterio
if you wish to install rasterio also
Upvotes: 0
Reputation: 51
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
Upvotes: 2
Reputation: 156
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.
Upvotes: 5