If you are interested in this article I assume you recently tried to use gdal with anaconda for one project or another and have run into a problem. So the quick solution for your problem is...
Create a new virtual environment and install gdal in that environment!!
After encountering countless problems with python with different projects, the golden rule I've learned is: always create a virtual environment for your project!
If you are still reading this it means you would like a detailed explanation (or maybe for some reason you like me rambling about gdal of all things!).
So one of my friends was working on a data science project and was running into a lot of issues and asked me to take a look at his project to see if I could get it to run.
The error he was encountering was: DLL load failed: The specified procedure could not be found
So the solution here is to create a new virtual environment in anaconda using conda in the terminal (if on windows you can use the anaconda-prompt terminal). Open the folder where you want to create the project and then follow these steps:
First update conda if necessary using:
conda update conda
Then we can proceed to creating a virtualenv (short for virtual environment) using:
conda create -n yourenvname
Now activate your virtualenv using:
conda activate yourenvname
Now just execute the following statement and it will install all dependencies as well as make any changes required
conda install gdal
I was using jupyter notebooks so I will open that (this should work fine with spyder as well):
anaconda-navigator
Open jupyter-notebook (the virtualenv will be selected by default)
In the first cell execute
from osgeo import gdal
The cell will execute without errors!
Cheers!!!
Top comments (0)