{"id":23348,"library":"bech32m","title":"Bech32m","description":"Python library for encoding and decoding Bech32 and Bech32m addresses (Bitcoin improvement BIP-350). Version 1.0.0 supports Python 3.9+ with a stable API based on BIP-0173 and BIP-0350. Release cadence is low; maintained on GitHub.","status":"active","version":"1.0.0","language":"python","source_language":"en","source_url":"https://github.com/ods/bech32m","tags":["bitcoin","bech32","bech32m","encoding","decoding","bip-350"],"install":[{"cmd":"pip install bech32m","lang":"bash","label":"Standard install"}],"dependencies":[{"reason":"Used for type hints on Python <3.11","package":"typing_extensions","optional":true}],"imports":[{"note":"The bech32m library uses module 'bech32m', not 'bech32'. The old 'bech32' library is a different package.","wrong":"from bech32 import bech32_encode","symbol":"bech32_encode","correct":"from bech32m import bech32_encode"},{"note":"Same as above; ensure you import from bech32m.","wrong":"from bech32 import bech32_decode","symbol":"bech32_decode","correct":"from bech32m import bech32_decode"}],"quickstart":{"code":"import os\nfrom bech32m import bech32_encode, bech32_decode\n\nhrp = \"bc\"\n# Convert bytes to 5-bit groups internally\ndata = [0, 1, 2, 3, 4, 5]\naddr = bech32_encode(hrp, data)\nprint(\"Encoded:\", addr)\n\n# Decode\nhrp_got, data_got = bech32_decode(addr)\nprint(\"Decoded HRP:\", hrp_got)\nprint(\"Decoded data:\", data_got)\n","lang":"python","description":"Encode and decode a Bech32m address (BIP-350). The data argument is a list of 5-bit integers."},"warnings":[{"fix":"Use 'from bech32m import ...' instead of 'from bech32 import ...'. Uninstall 'bech32' if present.","message":"The library bech32m is NOT the same as the old 'bech32' library. Import paths differ and APIs are not compatible.","severity":"breaking","affected_versions":"all"},{"fix":"Convert bytes to 5-bit groups using a conversion function (e.g., ods/bech32m provides a utility, but the main API does not include one; handle this externally).","message":"The encoding functions expect data in 5-bit groups (integers 0-31). Passing raw bytes will silently produce incorrect addresses.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install correct package: pip install bech32m and use 'from bech32m import ...'","cause":"Trying to import from deprecated/nonexistent module 'bech32' after installing 'bech32m'.","error":"ModuleNotFoundError: No module named 'bech32'"},{"fix":"Use 'bech32m.bech32_encode' (or 'bech32m.bech32_decode').","cause":"Using incorrect function name 'encode' instead of 'bech32_encode'.","error":"AttributeError: module 'bech32m' has no attribute 'encode'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}