{"id":21760,"library":"pylibdmtx","title":"pylibdmtx","description":"Python library for reading and writing Data Matrix barcodes, wrapping the libdmtx C library. Current version 0.1.10, low release cadence.","status":"active","version":"0.1.10","language":"python","source_language":"en","source_url":"https://github.com/NaturalHistoryMuseum/pylibdmtx/","tags":["barcode","datamatrix","decoding","encoding","libdmtx","Pillow"],"install":[{"cmd":"pip install pylibdmtx","lang":"bash","label":"pip"},{"cmd":"conda install -c conda-forge pylibdmtx","lang":"bash","label":"conda"}],"dependencies":[{"reason":"Required for opening and processing images.","package":"Pillow","optional":false},{"reason":"Shared library dependency; must be installed on the system.","package":"libdmtx","optional":false}],"imports":[{"note":"Top-level import does not expose decode; must import from submodule.","wrong":"import pylibdmtx","symbol":"decode","correct":"from pylibdmtx.pylibdmtx import decode"},{"note":"","wrong":"","symbol":"encode","correct":"from pylibdmtx.pylibdmtx import encode"}],"quickstart":{"code":"from PIL import Image\nfrom pylibdmtx.pylibdmtx import decode\n\nimage = Image.open('datamatrix.png')\nresults = decode(image)\nfor result in results:\n    print(result.data.decode('utf-8'))","lang":"python","description":"Decode a Data Matrix barcode from an image file."},"warnings":[{"fix":"Install via conda-forge (includes bundled DLL) or copy libdmtx.dll to a PATH directory.","message":"On Windows, libdmtx.dll must be in PATH. Use conda or manually add DLL directory.","severity":"breaking","affected_versions":"all"},{"fix":"Use result.data.decode('utf-8') or appropriate encoding.","message":"decode() returns bytes, not str. Must call .decode('utf-8') on data.","severity":"gotcha","affected_versions":"all"},{"fix":"Always pass a PIL Image object to decode().","message":"Input image must be PIL Image, not file path. Open with Image.open() first.","severity":"gotcha","affected_versions":"all"},{"fix":"Use Python 3.6+.","message":"Python 2 support is deprecated; library still installs but may break on Python 2 EOL.","severity":"deprecated","affected_versions":"<=0.1.10"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install libdmtx via system package manager: apt-get install libdmtx0 (Debian/Ubuntu) or brew install libdmtx (macOS).","cause":"libdmtx shared library not installed on Linux/macOS.","error":"OSError: libdmtx.so: cannot open shared object file"},{"fix":"Use: from pylibdmtx.pylibdmtx import decode","cause":"Importing from the top-level package instead of the submodule.","error":"ImportError: cannot import name 'decode' from 'pylibdmtx'"},{"fix":"Check result is not None before accessing .data.","cause":"decode() returned None (no barcode found).","error":"AttributeError: 'NoneType' object has no attribute 'decode'"},{"fix":"Open with Image.open(BytesIO(...)) to create PIL Image.","cause":"Passing a BytesIO object directly instead of a PIL Image.","error":"TypeError: expected str, bytes or os.PathLike object, not BytesIO"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}