{"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,"search_vec":"'21.2.0':27 '3.10':30 '3.14':43 'color':22 'current':24 'develop':13,52 'event':47 'field':16 'field-of-view':15 'free':40 'free-thread':39 'game':12,51 'game-develop':50 'handl':23 'improv':48 'librari':9 'libtcod':7,53 'nois':20 'offici':3 'pathfind':19 'port':5 'provid':14 'python':4,29,42 'regular':34 'releas':31 'requir':28 'roguelik':11,49 'sdl':54 'sdl3':38 'semi':33 'semi-regular':32 'support':36 'tcod':1 'termin':55 'thread':41 'version':25 'view':18 'wheel':45","created_at":"2026-05-09T05:54:53.157734+00:00","updated_at":"2026-05-09T05:54:53.157734+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://python-tcod.readthedocs.io/en/latest/","github":"https://github.com/libtcod/python-tcod","docs":"https://python-tcod.readthedocs.io","changelog":"https://github.com/libtcod/python-tcod/blob/main/CHANGELOG.md","pypi":"https://pypi.org/project/tcod/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}