Segno
Segno is a pure Python library for generating QR Codes and Micro QR Codes according to ISO/IEC 18004:2015(E). It provides various serialization formats like Scalable Vector Graphics (SVG), Portable Network Graphics (PNG), Encapsulated PostScript (EPS), Portable Document Format (PDF), and more, without external dependencies for these core functionalities. Currently at version 1.6.6, Segno maintains an active release cadence with several updates per year.
Warnings
- breaking Segno dropped support for Python 2.7 starting from version 1.6.0. Python 2.7 reached its End-of-Life on January 1, 2020.
- breaking Starting with Segno 1.6.0, the internal dependency on `pkg_resources` was removed and replaced by `importlib.metadata`. For Python versions older than 3.10, this introduces a new explicit dependency on the `importlib-metadata` backport package.
- gotcha Segno releases 1.6.4 and 1.6.5 (fixed in 1.6.6) had packaging issues where man pages were placed in the wrong directory or source distributions did not include all relevant files. While fixed, this highlights a potential for minor distribution-related glitches in point releases.
- gotcha In versions prior to 1.3.3, the `segno.helpers.make_wifi` and `segno.helpers.make_wifi_data` functions could generate invalid data if input strings contained characters that could be misinterpreted as integers.
Install
-
pip install segno
Imports
- make
import segno qrcode = segno.make('Your data') - helpers
from segno import helpers
Quickstart
import segno
# Create a QR code for a URL
qrcode = segno.make('https://example.com/your-data')
# Save the QR code as a PNG file with a scale of 5
qrcode.save('my_qrcode.png', scale=5)
# Or save as SVG
# qrcode.save('my_qrcode.svg', scale=5)
# Create a colorful QR code
colorful_qrcode = segno.make('https://example.com/colorful', dark='darkblue', light='lightblue')
colorful_qrcode.save('my_colorful_qrcode.png', scale=5)
print('QR codes generated successfully: my_qrcode.png and my_colorful_qrcode.png')