Skip to main content

How to Install Python GDAL on OS X

· 2 min read

If you're interested in creating accessible, interactive maps using Scalable Vector Graphics (SVG), you might already be familiar with the remarkable tool, Kartograph. This article aims to shed light on a common installation hurdle faced while setting up an essential component for Kartograph: the Geospatial Data Abstraction Library (GDAL).

GDAL, for those who may not know, is a powerful translator library for raster and vector geospatial data formats. This library's functionality is paramount to the seamless operation of Kartograph.

However, installing GDAL directly on Mac OS X using the pip command (pip install GDAL) can sometimes trigger an error. If you're struggling with this issue, here is the error message you would likely encounter:

main.gdal_config_error: [Errno 2] No such file or directory osx

Surprisingly, the solution to this error is quite straightforward, albeit not well-documented.

To rectify this, you need to use the terminal to install GDAL, but instead of using pip directly, we'll utilize Homebrew. Homebrew is a versatile package manager for OS X that simplifies the installation process of software on Apple's macOS operating system and Linux.

Follow the steps below:

  1. Open the terminal on your Mac. You can find the Terminal application through Finder, under Applications -> Utilities.

  2. Install GDAL using Homebrew by typing the following command and pressing Enter:

brew install gdal  
  1. Once GDAL has been installed through Homebrew, run the pip install command again:
sudo pip install GDAL

And voila! You have successfully resolved the error.

To confirm the successful installation of GDAL, type 'pip freeze' in the terminal. This command will generate a list of all installed packages. Verify that GDAL is listed among the output.

By overcoming this installation hurdle, you can fully exploit the capabilities of the Kartograph tool and create impressive, interactive SVG maps with ease.