Last modified: Jun 09, 2025 By Alexander Williams

Install Cartopy in Python - Quick Guide

Cartopy is a Python library for geospatial data visualization. It works with Matplotlib to create maps. This guide will help you install Cartopy quickly.

Prerequisites for Cartopy

Before installing Cartopy, ensure you have Python 3.6 or later. You also need Matplotlib installed. Basic knowledge of Python is helpful.

Cartopy depends on several libraries. These include NumPy, Shapely, and PROJ. Some may install automatically with Cartopy.

Install Cartopy Using pip

The easiest way to install Cartopy is with pip. Run this command in your terminal:


pip install cartopy

This will download and install Cartopy and its dependencies. The process may take a few minutes.

Verify the Installation

After installation, verify it works. Open Python and try importing Cartopy:


import cartopy
print(cartopy.__version__)

If no errors appear, Cartopy installed correctly. You should see the version number.

Common Installation Issues

Some users face issues during installation. Here are common problems and solutions:

PROJ errors: Ensure PROJ is installed. On Linux, use sudo apt-get install proj-bin.

Missing dependencies: Install required packages first. Check the Cartopy documentation.

Basic Cartopy Example

Here's a simple example to test Cartopy. It creates a basic map:


import matplotlib.pyplot as plt
import cartopy.crs as ccrs

fig = plt.figure(figsize=(10, 5))
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
ax.coastlines()
plt.show()

This code shows a world map with coastlines. It uses Plate Carrée projection.

Alternative Installation Methods

If pip doesn't work, try these alternatives:

conda: Use conda install -c conda-forge cartopy for Anaconda users.

Source: Download from GitHub and install manually. This is for advanced users.

Working with GeoPandas

Cartopy works well with GeoPandas. Together, they handle geospatial data effectively.

For shapefile support, consider pyshp. It's another useful geospatial library.

Conclusion

Installing Cartopy in Python is straightforward with pip. Verify the installation with a simple test script.

For more geospatial work, explore pygeoip. Cartopy is powerful for map visualizations.

Now you're ready to create beautiful maps with Python and Cartopy!