Install & Compatibility
Where this runs
tested against v2.7.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
build_error
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 16.9s · import 5.569s · 504MB
515MB installed
● package 515MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Moran
✓ from esda import Moran
Moran_Local
✓ from esda import Moran_Local
✗ from esda.moran import Moran_Local
Moran_Local is directly importable from esda since v2.0.
Geary
✓ from esda import Geary
Getis_Ord_G
✓ from esda import Getis_Ord_G
Compute Global Moran's I with a K-nearest neighbors weight matrix.
import libpysal
from esda import Moran
import numpy as np
# Generate random data and a spatial weights matrix
np.random.seed(123)
y = np.random.random(100)
w = libpysal.weights.KNN(k=5, ids=np.arange(100))
# Compute Global Moran's I
mi = Moran(y, w)
print(f"Moran's I: {mi.I:.3f}, p-value: {mi.p_sim:.3f}")
# Output: Moran's I: -0.022, p-value: 0.632
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'esda.moran'
Trying to import Moran_Local from the wrong submodule.
fixUse `from esda import Moran_Local` instead of `from esda.moran import Moran_Local`.
ValueError: The weights matrix is not row-standardized.
Moran class expects row-standardized weights by default.
fixUse `w.transform = 'R'` before passing to Moran, or create weights with row-standardization (e.g., `libpysal.weights.KNN(..., transform='R')`).
AttributeError: 'Moran' object has no attribute 'I'
The object was not created correctly; perhaps `y` is not numeric or `w` is invalid.
fixEnsure `y` is a 1D numeric array and `w` is a properly initialized libpysal weights object.
Upgrade
Version history
2.9.0latest on PyPI · released Mar 20, 2026
Audit
Dependencies
libpysalrequiredProvides spatial weights (W) and core spatial data structures.
scipyrequiredUsed for statistical distributions and randomizations.
numpyrequiredCore array operations.
shapelyoptionalRequired for geometric operations in shape and map_comparison modules.
pandasoptionalUsed for data handling in some utilities.