Last modified: Jun 01, 2025 By Alexander Williams

How to Install pyproj in Python for Projections

pyproj is a Python library for cartographic projections and coordinate transformations. It is widely used in GIS applications. This guide will help you install it easily.

What is pyproj?

pyproj is a Python interface to the PROJ library. It allows you to convert geographic coordinates between different projections. This is useful for mapping and spatial analysis.

It is often used alongside libraries like GeoPandas and Cartopy for advanced geospatial tasks.

Prerequisites

Before installing pyproj, ensure you have Python installed. A Python version of 3.6 or higher is recommended. You will also need pip, Python's package manager.

Check your Python version with:


import sys
print(sys.version)


3.9.7 (default, Sep 16 2021, 16:59:28) 
[GCC 8.4.0]

Install pyproj Using pip

The easiest way to install pyproj is using pip. Open your terminal or command prompt and run:


pip install pyproj

This will download and install the latest version of pyproj along with its dependencies.

Verify the Installation

After installation, verify it works by importing it in Python:


import pyproj
print(pyproj.__version__)


3.3.1

Basic Usage of pyproj

Here’s a simple example to transform coordinates from WGS84 to UTM Zone 33N:


from pyproj import Transformer

transformer = Transformer.from_crs("EPSG:4326", "EPSG:32633")
x, y = transformer.transform(52.5200, 13.4050)  # Berlin coordinates
print(x, y)


459585.789 5818992.708

This converts latitude and longitude to UTM coordinates. The Transformer class makes it easy to handle projections.

Common Issues and Fixes

If you encounter errors during installation, try these fixes:

1. PROJ Dependency Missing: On Linux, install PROJ development libraries first:


sudo apt-get install libproj-dev proj-data proj-bin

2. Upgrade pip: An outdated pip can cause issues. Upgrade it with:


pip install --upgrade pip

3. Use a Virtual Environment: Conflicts with other packages can be avoided using a virtual environment.

Advanced Features

pyproj supports advanced geospatial operations. For example, you can calculate geodesic distances:


from pyproj import Geod

geod = Geod(ellps="WGS84")
lon1, lat1 = 13.4050, 52.5200  # Berlin
lon2, lat2 = 2.3522, 48.8566   # Paris
az12, az21, dist = geod.inv(lon1, lat1, lon2, lat2)
print(f"Distance: {dist / 1000:.2f} km")


Distance: 878.47 km

This calculates the distance between Berlin and Paris using the WGS84 ellipsoid.

Conclusion

Installing pyproj in Python is straightforward with pip. It is a powerful tool for handling map projections and coordinate transformations.

For more geospatial tasks, check out Basemap or Rasterio. Happy coding!