skillfed

clingo

CFFI-based bindings to the clingo solver.

clingo v5.8.2 157.8K downloads/30d#10,745 on PyPI822
Permissive license MIT Active released

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 clingo

uv

uv add clingo

poetry

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 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

answer set programming solverlogic programming pythoncombinatorial problem solverASP solver bindingsclingo python interfaceconstraint solving logicdeclarative problem modeling
logic-programmingconstraint-solvingcombinatorial-optimization

More Artificial Intelligence packages