{"id":6192,"library":"pyqrcode","title":"PyQRCode","description":"PyQRCode is a pure Python library for generating QR codes. It supports various output formats including SVG, EPS, PNG (with the optional `pypng` dependency), XBM, and plain text for terminal display. It aims to simplify QR code creation while offering granular control over properties like error correction level, version, and encoding mode. The library automates most of the QR code building process, making it easy to generate codes with just a few lines of code. The current version is 1.2.1, with the last significant update in June 2018, suggesting a maintenance-only release cadence.","status":"maintenance","version":"1.2.1","language":"en","source_language":"en","source_url":"https://github.com/mnooner256/pyqrcode","tags":["QR code","generator","image","SVG","PNG","pure-python"],"install":[{"cmd":"pip install pyqrcode","lang":"bash","label":"Core library"},{"cmd":"pip install pypng","lang":"bash","label":"Optional: For PNG output"}],"dependencies":[{"reason":"Required for saving QR codes as PNG image files.","package":"pypng","optional":true}],"imports":[{"symbol":"pyqrcode","correct":"import pyqrcode"},{"note":"The `create` function is directly available in the `pyqrcode` module, not as a submodule. Alternatively, call `pyqrcode.create()` after `import pyqrcode`.","wrong":"import pyqrcode.create","symbol":"create","correct":"from pyqrcode import create"}],"quickstart":{"code":"import pyqrcode\nimport sys\n\n# Create a QR code for a URL\nqr_code_url = pyqrcode.create('https://example.com')\n\n# Save as SVG file\nqr_code_url.svg('example-url.svg', scale=8)\nprint(\"QR code saved as example-url.svg\")\n\n# Print to terminal (requires a compatible terminal)\nprint(\"\\nQR code in terminal:\")\nprint(qr_code_url.terminal(quiet_zone=1))","lang":"python","description":"This quickstart generates a QR code for a given URL, saves it as an SVG file, and displays it directly in a compatible terminal. For PNG output, ensure 'pypng' is installed."},"warnings":[{"fix":"Install `pypng`: `pip install pypng`.","message":"To generate PNG images, the `pypng` library must be installed separately (`pip install pypng`). Without it, calls to `qr_code.png()` will result in an error.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider alternatives like `qrcode` for ongoing development or if advanced features and active maintenance are crucial.","message":"The library has not seen significant updates since 2018 (version 1.2.1). While functional, it may lack modern features, performance optimizations, or compatibility with very recent Python versions compared to more actively maintained QR code libraries.","severity":"deprecated","affected_versions":"1.2.1 and potentially earlier"},{"fix":"Specify the `error` parameter: `pyqrcode.create('data', error='L')`.","message":"By default, `pyqrcode.create()` uses the highest error correction level ('H'). While this makes the QR code more robust to damage, it significantly reduces the data capacity. If you need to encode more data, you might need to manually set a lower error correction level (e.g., 'L', 'M', or 'Q') using the `error` parameter.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Avoid naming your scripts or variables `pyqrcode`.","message":"Naming a Python file or variable `pyqrcode.py` or `pyqrcode` can lead to import conflicts (module shadowing), where Python tries to import your local file/variable instead of the installed `pyqrcode` library.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}