{"id":28081,"library":"pycosat","title":"pycosat","description":"Python bindings to PicoSAT, a popular SAT solver written in C. Version 0.6.6 is the latest. The library is mature but receives infrequent updates; it is in maintenance mode.","status":"maintenance","version":"0.6.6","language":"python","source_language":"en","source_url":"https://github.com/ContinuumIO/pycosat","tags":["SAT","solver","picosat","cnf"],"install":[{"cmd":"pip install pycosat","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"itersolve is the generator version; solve is not a public function in pycosat.","wrong":"from pycosat import solve","symbol":"itersolve","correct":"from pycosat import itersolve"}],"quickstart":{"code":"import pycosat\n# Solve a SAT problem: each clause is a list of integers\ncnf = [[1, -2], [-1, 3], [-2, -3]]\nsolution = pycosat.itersolve(cnf)\nfor sol in solution:\n    print(sol)","lang":"python","description":"Solve a simple CNF SAT problem using the generator itersolve."},"warnings":[{"fix":"Replace `pycosat.solve(...)` with `next(pycosat.itersolve(...))` for a single solution.","message":"The function `solve` is not available; use `itersolve` or `blocksolve`.","severity":"deprecated","affected_versions":">=0.6"},{"fix":"Upgrade to 0.6.4 or later: `pip install --upgrade pycosat`.","message":"In version 0.6.4, a memory leak was fixed in `blocksolve()`. If you rely on heavy iteration, upgrade to avoid cumulative memory usage.","severity":"breaking","affected_versions":"<0.6.4"},{"fix":"Convert your problem to DIMACS CNF (list of lists of non-zero integers, no 0).","message":"pycosat only accepts DIMACS CNF format, not other SAT formats like DIMACS WCNF or OPB. Variables must be positive integers.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `next(pycosat.itersolve(cnf))` or `list(pycosat.itersolve(cnf))`.","cause":"pycosat does not expose a `solve` function; use `itersolve` or `blocksolve` instead.","error":"AttributeError: module 'pycosat' has no attribute 'solve'"},{"fix":"Upgrade to 0.6.4+ and consider splitting the problem into smaller chunks.","cause":"pycosat uses the PicoSAT library which may allocate large arrays for huge CNF formulas. Also, a memory leak in versions <0.6.4 could cause OOM.","error":"MemoryError: Unable to allocate ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}