PyQRCode

1.2.1 · maintenance · verified Tue Apr 14

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.

Warnings

Install

Imports

Quickstart

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.

import pyqrcode
import sys

# Create a QR code for a URL
qr_code_url = pyqrcode.create('https://example.com')

# Save as SVG file
qr_code_url.svg('example-url.svg', scale=8)
print("QR code saved as example-url.svg")

# Print to terminal (requires a compatible terminal)
print("\nQR code in terminal:")
print(qr_code_url.terminal(quiet_zone=1))

view raw JSON →