--- id: clingo version: "5.8.2" license: MIT license_treatment: permissive maintenance: active --- # clingo — CFFI-based bindings to the clingo solver. License: permissive · Maintenance: active · Downloads: 157.8K/mo ## 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 above — 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 pip install clingo uv add clingo poetry add clingo ## Installing 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_current - Install friction: medium - Maintenance: active - Downloads: 157.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags answer set programming solver, logic programming python, combinatorial problem solver, ASP solver bindings, clingo python interface, constraint solving logic, declarative problem modeling, logic-programming, constraint-solving, combinatorial-optimization [View on SkillFed](https://skillfed.io/packages/clingo) · [View on PyPI](https://pypi.org/project/clingo/)