clingo
CFFI-based bindings to the clingo solver.
What it is and what it does
Clingo is a Python interface to the clingo Answer Set Programming solver, part of the Potassco project. It lets you express combinatorial problems—scheduling, configuration, planning, constraint satisfaction—as declarative logic programs rather than imperative algorithms. You write rules describing what solutions must satisfy, and clingo computes all answer sets (solutions) that satisfy those rules. The package wraps the C++ clingo engine via CFFI, giving you access to the solver's full capabilities from Python.
Typical workflows involve creating a Control object, adding logic program rules as strings, grounding the program (instantiating it with concrete data), and then calling solve() to enumerate or find solutions. It's used for problems where you want to specify constraints and let the solver find valid assignments, rather than writing search code yourself.
Use it for:
- Solve scheduling and resource allocation problems by encoding constraints as logic rules and computing valid schedules.
- Perform configuration management or product configuration by modeling dependencies and constraints as ASP rules.
- Solve combinatorial puzzles (Sudoku, graph coloring, N-queens) by expressing the rules and letting clingo find all solutions.
- Perform planning and reasoning tasks where you need to compute all possible action sequences satisfying given goals.
- Prototype constraint satisfaction problems quickly without implementing custom search algorithms.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Clingo is a Python binding to the clingo Answer Set Programming solver, allowing you to model and solve combinatorial logic problems by writing logic programs and computing their answer sets.
Yes, if you need to solve combinatorial or constraint satisfaction problems and prefer declarative logic programming over imperative search. The package is actively maintained, has no known vulnerabilities, and carries a permissive license. Medium install friction is acceptable for most platforms. Not necessary if your problems fit standard optimization libraries or if you prefer imperative constraint solvers.
Install
clingo on PyPI
pip
pip install clingouv
uv add clingopoetry
poetry add clingoInstalling clingo
Before you install
Medium install friction due to compiled C extensions; pre-built wheels cover most common platforms (macOS x86_64 and ARM, Linux x86_64/i686/aarch64/ppc64le, Windows). Dependency on cffi is straightforward. Package is actively maintained with a recent release.
License in practice
MIT license is permissive; you can use, modify, and distribute clingo with minimal restrictions, making it suitable for both open-source and proprietary projects.
Quickstart
pip install clingo
import clingo
ctl = clingo.Control()
ctl.add("base", [], "a :- not b. b :- not a.")
ctl.ground([("base", [])])
ctl.solve(on_model=lambda m: print(m))
Requires Python 3.6 or later; compiled wheels available for common platforms but may require build tools on unsupported architectures.
Verify before relying
- Whether the package includes pre-built wheels for all Python versions beyond 3.10 and 3.11 (fact sheet shows only 3.10 and 3.11 wheels).
- Performance characteristics and typical solve time for different problem sizes and complexity classes.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — cffi |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 157,813/month — #10,745 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: clingo-5.8.2-cp310-cp310-macosx_10_9_x86_64.whl; clingo-5.8.2-cp310-cp310-macosx_11_0_arm64.whl; clingo-5.8.2-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; clingo-5.8.2-cp310-cp310-manylinux_2_26_i686.manylinux_2_28_i686.whl; clingo-5.8.2-cp310-cp310-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl; clingo-5.8.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; clingo-5.8.2-cp310-cp310-musllinux_1_2_i686.whl; clingo-5.8.2-cp310-cp310-musllinux_1_2_x86_64.whl; clingo-5.8.2-cp310-cp310-win32.whl; clingo-5.8.2-cp310-cp310-win_amd64.whl; clingo-5.8.2-cp311-cp311-macosx_10_9_x86_64.whl; clingo-5.8.2-cp311-cp311-macosx_11_0_arm64.whl; clingo-5.8.2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; clingo-5.8.2-cp311-cp311-manylinux_2_26_i686.manylinux_2_28_i686.whl; clingo-5.8.2-cp311-cp311-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl; clingo-5.8.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; clingo-5.8.2-cp311-cp311-musllinux_1_2_i686.whl; clingo-5.8.2-cp311-cp311-musllinux_1_2_x86_64.whl; clingo-5.8.2-cp311-cp311-win32.whl; clingo-5.8.2-cp311-cp311-win_amd64.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
advent-of-codeProvides pre-computed solutions to Advent of…
unclear · top 15,000 on PyPI
python-constraintSolves constraint satisfaction problems (CSPs)…
permissive · top 15,000 on PyPI
mipPython MIP models and solves mixed-integer…
copyleft · top 15,000 on PyPI
pycosatProvides efficient Python bindings to PicoSAT,…
permissive · top 15,000 on PyPI
PuLPPuLP is a linear and mixed-integer programming…
permissive · top 5,000 on PyPI
pyomoPyomo is a Python framework for formulating and…
permissive · top 5,000 on PyPI
kiwisolverkiwisolver is a Python binding to a fast C++…
permissive · top 1,000 on PyPI
claripyClaripy is an abstraction layer for constraint…
permissive · top 5,000 on PyPI
optlangOptlang formulates and solves linear,…
permissive · top 15,000 on PyPI
docplexModeling library for building and solving…
permissive · top 15,000 on PyPI