{"id":28319,"library":"tcod","title":"tcod","description":"The official Python port of libtcod, a library for roguelike game development providing field-of-view, pathfinding, noise, and color handling. Current version is 21.2.0 (requires Python >=3.10), released semi-regularly with support for SDL3, free-threaded Python (3.14t wheels), and event improvements.","status":"active","version":"21.2.0","language":"python","source_language":"en","source_url":"https://github.com/libtcod/python-tcod","tags":["roguelike","game-development","libtcod","sdl","terminal"],"install":[{"cmd":"pip install tcod","lang":"bash","label":"Install latest stable"}],"dependencies":[{"reason":"PyPI package name is 'tcod' but sometimes referred to as 'python-tcod' in documentation; both refer to same package.","package":"python-tcod","optional":false}],"imports":[{"note":"No common mistake; import tcod is standard.","wrong":"","symbol":"tcod","correct":"import tcod"},{"note":"tcod.event is a module but not a subpackage; use from tcod import event.","wrong":"import tcod.event","symbol":"tcod.event","correct":"from tcod import event"},{"note":"KeySym is in tcod.event, not top-level tcod.","wrong":"from tcod import KeySym","symbol":"KeySym","correct":"from tcod.event import KeySym"}],"quickstart":{"code":"import tcod\nimport os\n\ndef main() -> None:\n    tileset = tcod.tileset.load_tilesheet(\n        \"dejavu10x10_gs_tc.png\", 32, 8, tcod.tileset.CHARMAP_TCOD\n    )\n    with tcod.context.new(\n        columns=40,\n        rows=30,\n        tileset=tileset,\n        title=\"Hello World\",\n    ) as context:\n        console = tcod.Console(40, 30)\n        console.print(0, 0, \"Hello World\")\n        while True:\n            context.present(console)\n            for event in tcod.event.wait():\n                if event.type == tcod.event.Quit:\n                    raise SystemExit()\n\nif __name__ == \"__main__\":\n    main()","lang":"python","description":"Minimal tcod application: load tileset, create context, print text, and run event loop until quit."},"warnings":[{"fix":"Use tcod.event.KeySym.UP or KeySym[\"UP\"] instead of tcod.event.K_UP. For PY3.13+, KeySym.UP works; for older Python use KeySym['UP'].","message":"Event key symbols changed: uppercase constants like K_UP are deprecated; use KeySym.UP or KeySym['UP']. Lowercase constants were removed in 19.6.0 but partially restored for PY3.13+.","severity":"breaking","affected_versions":">=19.6.0"},{"fix":"Check for None before unpacking: logical_size = renderer.logical_size; if logical_size: width, height = logical_size","message":"Renderer.logical_size returns None instead of (0,0) when unset (tcod 20.0.0+).","severity":"breaking","affected_versions":">=20.0.0"},{"fix":"Replace set_tile(codepoint, tile) with tileset[codepoint] = tile and get_tile(codepoint) with tileset[codepoint].","message":"Tileset.set_tile and Tileset.get_tile deprecated since 20.1.0, replaced by dict-like access: tileset[codepoint] = tile.","severity":"deprecated","affected_versions":">=20.1.0"},{"fix":"Set os.environ['SDL_RENDER_SCALE_QUALITY'] = 'linear' before import tcod for linear interpolation scaling.","message":"SDL_RENDER_SCALE_QUALITY must be set via os.environ before importing tcod to affect scaling; defaults to nearest since 19.5.0.","severity":"gotcha","affected_versions":">=19.5.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run 'pip install tcod' in your active Python environment.","cause":"tcod package not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'tcod'"},{"fix":"Use 'from tcod import event' first, then access event.*.","cause":"Attempting to use import tcod then tcod.event, but event is a submodule that must be imported explicitly.","error":"AttributeError: module 'tcod' has no attribute 'event'"},{"fix":"Use 'from tcod.event import KeySym'.","cause":"KeySym is not in the top-level tcod module; it's in tcod.event.","error":"ImportError: cannot import name 'KeySym' from 'tcod'"},{"fix":"Provide correct path to a valid tilesheet image (e.g., 'dejavu10x10_gs_tc.png' from tcod's examples).","cause":"Tilesheet file path is incorrect or missing.","error":"tcod.error.TcodError: Could not find a tileset file"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}