haversine
Calculate the distance between 2 points on Earth.
Decision gist · record as of 2026-08-14
Yes. Haversine is a stable, dependency-free library for a common task. It has no known vulnerabilities, permissive licensing, and low install friction. The aging maintenance status (624 days since last release) is not a blocker for a mature, narrow-scope library—the formula itself does not change. Install it if you need to calculate distances between geographic coordinates; skip it only if you require more advanced geodetic calculations or are already using a larger geospatial framework.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Latitude must be in range [-90, 90] and longitude in range [-180, 180]; values outside these ranges will raise an error unless the normalize parameter is used.
- Low friction: pure Python wheel with no runtime dependencies.
- Maintenance status is aging—last release was 624 days ago, though the repository remains active with recent commits and the package is marked Production/Stable.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2024-11-28 (624 days) · last repo commit 2025-11-24 · 371 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,963,740 downloads/mo, #2,434 on PyPI
Alternatives
Verify before relying
pip install haversine
from haversine import haversine, Unit
lyon = (45.7597, 4.8422)
paris = (48.8567, 2.3508)
distance_km = haversine(lyon, paris)
distance_mi = haversine(lyon, paris, unit=Unit.MILES)- Accuracy of haversine formula results compared to other geodetic methods for long distances or polar regions.
- Performance characteristics of vector operations without optional numba and icc_rt dependencies installed.
- Whether the package handles edge cases like antipodal points or coordinates at the poles correctly.
What it is and what it does
Haversine is a lightweight Python library that computes the shortest distance between two points on Earth given their latitude and longitude coordinates. It implements the haversine formula, which calculates great-circle distances on a sphere, and supports output in kilometers, meters, miles, nautical miles, feet, inches, radians, and degrees. The package also provides an inverse haversine function to find a destination point given a starting point, distance, and direction.
The core use case is straightforward: pass two (lat, lon) tuples and get a distance back. For bulk operations, the library offers a vector mode that can compute distances between multiple point pairs; this mode optionally uses NumPy for performance and can be further accelerated with Numba and icc_rt. The package is pure Python with no mandatory dependencies, making it easy to integrate into any project that needs basic geographic distance calculations.
Use it for
- Calculate driving or travel distances between cities or landmarks for routing or trip planning applications.
- Filter nearby locations from a database by computing distances from a user's current position.
- Batch-compute pairwise distances between many geographic points for clustering or spatial analysis.
- Validate geographic coordinates or detect anomalies by checking distances between consecutive GPS readings.
- Find the closest facility (store, hospital, etc.) to a given location by comparing distances to multiple candidates.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Haversine is a stable, dependency-free library for a common task. It has no known vulnerabilities, permissive licensing, and low install friction. The aging maintenance status (624 days since last release) is not a blocker for a mature, narrow-scope library—the formula itself does not change. Install it if you need to calculate distances between geographic coordinates; skip it only if you require more advanced geodetic calculations or are already using a larger geospatial framework.
Install
haversine on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Maintenance status is aging—last release was 624 days ago, though the repository remains active with recent commits and the package is marked Production/Stable.
Latitude must be in range [-90, 90] and longitude in range [-180, 180]; values outside these ranges will raise an error unless the normalize parameter is used.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install haversine
from haversine import haversine, Unit
lyon = (45.7597, 4.8422)
paris = (48.8567, 2.3508)
distance_km = haversine(lyon, paris)
distance_mi = haversine(lyon, paris, unit=Unit.MILES)
Verify before relying
- Accuracy of haversine formula results compared to other geodetic methods for long distances or polar regions.
- Performance characteristics of vector operations without optional numba and icc_rt dependencies installed.
- Whether the package handles edge cases like antipodal points or coordinates at the poles correctly.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.5 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Aging 624 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,963,740 / month, #2,434 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: GISTopic :: Scientific/Engineering :: Mathematics |
Evidence: haversine-2.9.0-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “haversine distance calculation”
- haversineCalculates great-circle distances between geographic coordinates on…
- polylevenPolyleven computes Levenshtein distance between two strings using a…
- edtComputes Euclidean distance transforms for 1D, 2D, or 3D labeled…
Give your agent the search over MCP, or paste the wish link into any chat.
More Mathematics packages
NetworkX provides data structures and algorithms for creating, analyzing, and manipulating graphs and networks, supporting everything from simple undirected graphs to complex directed and weighted networks.
kiwisolver is a Python binding to a fast C++ implementation of the Cassowary constraint solver, enabling you to solve systems of linear constraints and inequalities.
Install it if you need to solve constraint systems; skip it if you only need simple linear algebra.
SymPy is a Python library for symbolic mathematics, performing algebraic manipulation, calculus, equation solving, and mathematical expression simplification without numerical approximation.
ContourPy calculates contours of 2D quadrilateral grids using C++11 algorithms wrapped in Python, offering serial and multithreaded implementations without requiring Matplotlib as a dependency.
PyTorch provides GPU-accelerated tensor computation and automatic differentiation for building and training deep neural networks in Python.
onnxruntime loads and executes Open Neural Network Exchange (ONNX) models with a focus on inference performance across CPUs and accelerators.
Install it if you have ONNX models to run in production or development.
See also geopy · global-land-mask · searoute · mgrs · timezonefinder · geohash2 · pyGeoTile · reverse-geocode · pymap3d · kerykeion