How to Download GDAL with Anaconda
Sharon Fitzpatrick
Coast Train DeveloperTutorial: How to Download GDAL with Anaconda.
Installing GDAL with Anaconda
Install Anaconda
First, you need to have Anaconda installed on your computer, download it here: https://www.anaconda.com/products/individual#Downloads
Second, once you have Anaconda successfully installed open it.
Create a virtual environment
We need to create a virtual environment within Anaconda to hold our installation of GDAL. An environment in Anaconda is like a separate space for your code to live in where it will not interfere with other code you have.
Run the command:
conda create --name pygdal
This will create an environment called "pygal" where we will later be installing gdal here. Quick Note: You can name your environment whatever you please, but in this tutorial and the following tutorials I will be using "pygdal" as the environment name.
Anaconda will prompt you asking if you want to proceed[y/n] : Type
y
Lastly, run the command:
conda activate pygdal
This command will activate your new environment named "pygdal".
Install GDAL
- Inside your virtual environment named "pygdal" run the command:
conda install conda-forge gdal
This will install the gdal package in the environment,"pygdal" you just created.
- A list of files will pop up and Anaconda will prompt you asking if you want to proceed[y/n] : Type
y
It will take a few minutes to finish downloading. When it is close to finishing you will see the following:
"
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
"
Verify Your Installation of GDAL
Run the command:
conda list gdal
This command verifies we have gdal installed. As you can see in the screenshot below I have version 3.3.1 .
Run the command:
python
This opens a python shell we can type commands into.
Run the command:
from osgeo import gdal
When we downloaded the gdal package we downloaded the entire osgeo library, which includes gdal. You should see output similar to the image below. If you get errors like "import GDAL not found" this means your installation failed.
Run the command:
exit()
This exits the python shell.
Congrats!๐ You successfully downloaded GDAL with Anaconda!
Helpful Links
- Anaconda's official Download Page for GDAL: https://anaconda.org/conda-forge/gdal
- Official GDAL Documentation: https://gdal.org/download.html