{"id":388,"library":"contourpy","title":"ContourPy: Contour Calculation for 2D Quadrilateral Grids","description":"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.","status":"active","version":"1.3.3","language":"python","source_language":"en","source_url":"https://github.com/contourpy/contourpy","tags":["contour","2D grids","Python","C++11","pybind11","Matplotlib","multithreading"],"install":[{"cmd":"pip install contourpy","lang":"bash","label":"Install ContourPy"}],"dependencies":[{"reason":"Required for numerical operations","package":"numpy","optional":false}],"imports":[{"note":"Ensure correct import path to access contour generation functions","symbol":"contour_generator","correct":"from contourpy import contour_generator"}],"quickstart":{"code":"import numpy as np\nfrom contourpy import contour_generator\n\n# Create a 2x2 grid of z values\nz = np.array([[0.0, 0.1], [0.2, 0.3]])\n\n# Initialize the contour generator\ncont_gen = contour_generator(z=z)\n\n# Calculate contour lines at z-level 0.25\nlines = cont_gen.lines(0.25)\n\n# Calculate filled contours between z-levels 0.15 and 0.25\nfilled = cont_gen.filled(0.15, 0.25)\n\n# Visualize the contours using Matplotlib\nimport matplotlib.pyplot as plt\n\nfig, ax = plt.subplots()\nfor line in lines:\n    ax.plot(line[:, 0], line[:, 1], color='red')\nfor polygon in filled[0]:\n    ax.fill(polygon[:, 0], polygon[:, 1], color='gold', alpha=0.5)\nplt.show()","lang":"python","description":"A simple example demonstrating how to use ContourPy to generate and visualize contour lines and filled contours from a 2x2 grid of z values."},"warnings":[{"fix":"Upgrade to Python 3.11 or later.","message":"Support for Python versions below 3.11 has been dropped in version 1.3.3.","severity":"breaking","affected_versions":"1.3.3"},{"fix":"Use with caution or opt for the serial version for stability.","message":"The multithreaded option in the newer algorithm is considered experimental.","severity":"deprecated","affected_versions":"1.3.0"},{"fix":"Install the 'matplotlib' package using `pip install matplotlib` or ensure it is included in the project's dependency management.","message":"Missing required package: 'matplotlib'. The package 'matplotlib' was not found in the environment, preventing the script from running.","severity":"breaking","affected_versions":"1.3.3"},{"fix":"Install the matplotlib package using 'pip install matplotlib'.","message":"The 'matplotlib' package is not installed, leading to a ModuleNotFoundError.","severity":"breaking","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-05-12T13:28:18.354Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Ensure `contourpy` is installed using `pip install contourpy` or `conda install -c conda-forge contourpy`.","cause":"The `contourpy` package is not installed in the current Python environment or is not accessible via `sys.path`.","error":"ModuleNotFoundError: No module named 'contourpy'"},{"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.","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.","error":"ERROR: Could not build wheels for contourpy, which is required to install pyproject.toml-based projects."},{"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.","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.","error":"ERROR: Could not find a version that satisfies the requirement contourpy==X.Y.Z (from versions: ...)"},{"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.","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.","error":"A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.0.dev0 as it may crash."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.2,"mem_mb":6.8,"disk_size":"94.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.17,"mem_mb":6.8,"disk_size":"87M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.32,"mem_mb":7.3,"disk_size":"101.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.28,"mem_mb":7.3,"disk_size":"94M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.3,"mem_mb":7.2,"disk_size":"90.2M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.28,"mem_mb":7.2,"disk_size":"82M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.24,"mem_mb":7.7,"disk_size":"89.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.28,"mem_mb":7.7,"disk_size":"81M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.21,"mem_mb":6.5,"disk_size":"101.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.17,"mem_mb":6.5,"disk_size":"97M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}