Last modified: Jun 09, 2025 By Alexander Williams

Install pyproj in Python - Quick Guide

Working with geospatial data in Python often requires handling map projections. pyproj is a Python interface to PROJ, a library for cartographic projections.

This guide will walk you through installing pyproj and using it for basic coordinate transformations.

What is pyproj?

pyproj is a Python library for performing cartographic transformations and geodetic computations. It provides tools for:

  • Converting between coordinate systems
  • Calculating distances between points
  • Transforming geospatial data between projections

If you work with GeoPandas or Cartopy, pyproj is often a dependency.

Installation Methods

There are several ways to install pyproj in Python. Choose the method that works best for your environment.

1. Using pip

The simplest way to install pyproj is with pip:


pip install pyproj

2. Using conda

If you use Anaconda or Miniconda, install pyproj from the conda-forge channel:


conda install -c conda-forge pyproj

3. Building from source

For advanced users who need the latest features:


git clone https://github.com/pyproj4/pyproj.git
cd pyproj
pip install .

Verifying the Installation

After installation, verify pyproj works correctly:


import pyproj
print(pyproj.__version__)


3.4.1  # Example output

Basic Usage Examples

Here are some common operations with pyproj.

Coordinate Transformation

Convert coordinates from WGS84 to Web Mercator:


from pyproj import Transformer

# Create transformer
transformer = Transformer.from_crs("EPSG:4326", "EPSG:3857")

# Transform coordinates (longitude, latitude)
x, y = transformer.transform(12.5, 55.5)

print(x, y)


1391561.06 7508808.32  # Example output

Distance Calculation

Calculate distance between two points:


from pyproj import Geod

geod = Geod(ellps="WGS84")
# Calculate distance from New York to London
lon1, lat1 = -74.0, 40.7
lon2, lat2 = 0.0, 51.5

az12, az21, dist = geod.inv(lon1, lat1, lon2, lat2)

print(f"Distance: {dist/1000:.1f} km")


Distance: 5585.3 km  # Example output

Troubleshooting Common Issues

If you encounter problems, try these solutions:

PROJ database errors: Update PROJ data with:


pyproj sync

Installation conflicts: Create a clean virtual environment before installing.

Version issues: Check compatibility with other geospatial libraries like pyshp.

Conclusion

pyproj is an essential tool for geospatial work in Python. With this guide, you should now have it installed and ready for your projects.

Remember to keep pyproj updated to access the latest projection databases and features. For more advanced geospatial operations, consider exploring related libraries.