{"id":21048,"library":"clingo","title":"clingo","description":"CFFI-based Python bindings to the clingo Answer Set Programming (ASP) solver. Version 5.8.0, released 2024-04-06. Cadence: irregular, roughly annual.","status":"active","version":"5.8.0","language":"python","source_language":"en","source_url":"https://github.com/potassco/clingo","tags":["answer set programming","ASP","solver","logic programming","potassco"],"install":[{"cmd":"pip install clingo","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"Direct class import is conventional.","wrong":"import clingo; ctl = clingo.Control()","symbol":"Control","correct":"from clingo import Control"},{"note":"Function is in clingo, not a submodule.","wrong":"from clingo.symbol import Function","symbol":"Function","correct":"from clingo import Function"}],"quickstart":{"code":"from clingo import Control\nctl = Control()\nctl.add(\"base\", [], \"a :- not b. b :- not a.\")\nctl.ground([(\"base\", [])])\nwith ctl.solve(yield_=True) as handle:\n    for model in handle:\n        print(model)\n","lang":"python","description":"Basic ASP solving: add rules, ground, and iterate over stable models."},"warnings":[{"fix":"Use the context manager: `with ctl.solve(yield_=True) as handle:` instead of `result = ctl.solve()`.","message":"From clingo 5.5 to 5.6, the `solve` method changed from returning a `SolveResult` to a `SolveHandle` with a context manager. In 5.4 and earlier, `ctl.solve()` returned a `SolveResult` directly.","severity":"breaking","affected_versions":">=5.6"},{"fix":"After the `with` block, use `handle.get()` to get satisfiability (e.g., `print(handle.get().satisfiable)`).","message":"The `clingo.solving.SolveResult` class was removed in 5.6. `solve()` now returns a `SolveHandle`, and the satisfiability is obtained via `solve()`'s return value after the context manager exits.","severity":"breaking","affected_versions":">=5.6"},{"fix":"Replace `ctl.load('file.lp')` with `with open('file.lp') as f: ctl.add('base', [], f.read()); ctl.ground([('base', [])])`.","message":"The `clingo.Control.load()` method is deprecated in 5.8 in favor of `Control.add()` + `Control.ground()`.","severity":"deprecated","affected_versions":"5.8"},{"fix":"Always use `with ctl.solve(yield_=True) as handle: for model in handle: print(model)`.","message":"Calling `Control.solve()` without `yield_=True` will not return models; you must iterate over the `SolveHandle` or use the context manager with `yield_=True`.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'-04':19 '-06':20 '2024':18 '5.8.0':16 'annual':24 'answer':10,25 'asp':13,28 'base':4 'bind':6 'cadenc':21 'cffi':3 'cffi-bas':2 'clingo':1,9 'irregular':22 'logic':30 'potassco':32 'program':12,27,31 'python':5 'releas':17 'rough':23 'set':11,26 'solver':14,29 'version':15","created_at":"2026-04-27T16:57:48.283300+00:00","updated_at":"2026-04-27T16:57:48.283300+00:00","problems":[{"fix":"Install via conda: `conda install -c potassco clingo`, or install from source with proper dependencies.","cause":"Clingo installed from PyPI may not work on systems without a compatible C compiler or prebuilt wheel (e.g., ARM macOS).","error":"ModuleNotFoundError: No module named 'clingo'"},{"fix":"Use `#const` directives, or ground the program properly, or avoid arithmetic on variables without domain bounds.","cause":"Using arithmetic expressions on ungrounded variables (e.g., `X = Y + 1`) without proper grounding.","error":"clingo.core.SolveError: undefined arithmetic operation"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"5.8.0","cli_name":"clingo","cli_version":"sh: 1: clingo: not found","type":"library","homepage":"https://potassco.org/clingo/","github":"https://github.com/potassco/clingo","docs":null,"changelog":null,"pypi":"https://pypi.org/project/clingo/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}