ContourPy: Contour Calculation for 2D Quadrilateral Grids
raw JSON → 1.3.3 verified Tue May 12 auth: no python install: verified quickstart: stale
ContourPy is a Python library for calculating contours of 2D quadrilateral grids, written in C++11 and wrapped using pybind11. It offers algorithms used in Matplotlib, including the 2005 and 2014 versions, as well as a newer algorithm with additional features available in both serial and multithreaded versions. The current version is 1.3.3, released on March 7, 2026, with a release cadence of approximately every 2-3 months.
pip install contourpy Common errors
error ModuleNotFoundError: No module named 'contourpy' ↓
cause The `contourpy` package is not installed in the current Python environment or is not accessible via `sys.path`.
fix
Ensure
contourpy is installed using pip install contourpy or conda install -c conda-forge contourpy. error ERROR: Could not build wheels for contourpy, which is required to install pyproject.toml-based projects. ↓
cause `pip` failed to compile the C++ extension of `contourpy` from source, often due to missing build tools (like a C++ compiler, `meson`, or `ninja`) or environment-specific issues.
fix
Install necessary build tools for your operating system (e.g.,
build-essential on Linux, Xcode on macOS, Visual C++ Build Tools on Windows) and then retry pip install contourpy. Alternatively, use conda install -c conda-forge contourpy to install pre-built binaries. error ERROR: Could not find a version that satisfies the requirement contourpy==X.Y.Z (from versions: ...) ↓
cause The specified version of `contourpy` is not available for your current Python version or operating system, or there is a conflict with other installed packages requiring a different Python version.
fix
Check the Python version compatibility requirements for the desired
contourpy version and upgrade your Python environment if needed. Try installing without a specific version constraint (pip install contourpy) to allow pip to find a compatible binary wheel, or manually select an older contourpy version known to be compatible with your Python. error A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.0.dev0 as it may crash. ↓
cause The `contourpy` library, or a dependency of it, was compiled against a different major version of NumPy than the one currently installed, leading to potential Application Binary Interface (ABI) incompatibility.
fix
Downgrade NumPy to a version compatible with
contourpy (typically <2.0 if contourpy hasn't released a 2.x compatible version) or upgrade contourpy to a version that officially supports NumPy 2.0. Reinstalling contourpy and its dependencies after adjusting NumPy versions is recommended. Warnings
breaking Support for Python versions below 3.11 has been dropped in version 1.3.3. ↓
fix Upgrade to Python 3.11 or later.
deprecated The multithreaded option in the newer algorithm is considered experimental. ↓
fix Use with caution or opt for the serial version for stability.
breaking Missing required package: 'matplotlib'. The package 'matplotlib' was not found in the environment, preventing the script from running. ↓
fix Install the 'matplotlib' package using `pip install matplotlib` or ensure it is included in the project's dependency management.
breaking The 'matplotlib' package is not installed, leading to a ModuleNotFoundError. ↓
fix Install the matplotlib package using 'pip install matplotlib'.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.20s 94.1M
3.10 slim (glibc) - - 0.17s 87M
3.11 alpine (musl) - - 0.32s 101.7M
3.11 slim (glibc) - - 0.28s 94M
3.12 alpine (musl) - - 0.30s 90.2M
3.12 slim (glibc) - - 0.28s 82M
3.13 alpine (musl) - - 0.24s 89.6M
3.13 slim (glibc) - - 0.28s 81M
3.9 alpine (musl) - - 0.21s 101.8M
3.9 slim (glibc) - - 0.17s 97M
Imports
- contour_generator
from contourpy import contour_generator
Quickstart stale last tested: 2026-04-23
import numpy as np
from contourpy import contour_generator
# Create a 2x2 grid of z values
z = np.array([[0.0, 0.1], [0.2, 0.3]])
# Initialize the contour generator
cont_gen = contour_generator(z=z)
# Calculate contour lines at z-level 0.25
lines = cont_gen.lines(0.25)
# Calculate filled contours between z-levels 0.15 and 0.25
filled = cont_gen.filled(0.15, 0.25)
# Visualize the contours using Matplotlib
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
for line in lines:
ax.plot(line[:, 0], line[:, 1], color='red')
for polygon in filled[0]:
ax.fill(polygon[:, 0], polygon[:, 1], color='gold', alpha=0.5)
plt.show()