Generate Custom QR Codes in Python with MyQR – A Complete Tutorial

This step‑by‑step guide shows how to install the MyQR library, import it in PyCharm, and create plain, image‑based, and colorized QR codes using simple Python code snippets, plus an overview of all available parameters.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Generate Custom QR Codes in Python with MyQR – A Complete Tutorial

Install the MyQR library

Open a command prompt (Windows+R → cmd) and run: pip install myqr Wait until the installation succeeds.

Import MyQR in PyCharm

In PyCharm open File → Settings → Project → Python Interpreter , click the + button, search for MyQR, select the first result and click Install Package . After installation you can start using the library.

Generate a basic QR code

Import the library and run:

from MyQR import myqr
myqr.run(words='https://baidu.com')

The script creates a file named qrcode.png in the same directory as the script.

Create a QR code with a custom image

Add the picture argument pointing to your image file:

from MyQR import myqr
myqr.run(
    words='https://baidu.com',
    picture='C:\\Users\\jinyj\\Desktop\\p1.png'
)

The resulting QR code blends the supplied picture.

Generate a colorized QR code

Set colorized=True (and optionally provide a picture) to produce a colored QR code:

from MyQR import myqr
myqr.run(
    words='https://baidu.com',
    picture='C:\\Users\\jinyj\\Desktop\\p1.png',
    colorized=True
)

Advanced parameters

MyQR supports many additional options. Example:

from MyQR import myqr
myqr.run(
    words='URL or text (no Chinese characters)',
    version=5,               # error‑correction level
    level='H',               # L, M, Q, H
    picture='image.png',
    colorized=True,
    contrast=1.0,
    brightness=1.0,
    save_name='mycode.png',
    save_dir=r'C:\Users'
)

You can also generate animated GIF QR codes by providing a .gif image.

Article originally published by Python之禅 (copyright belongs to the original author).

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Pythoncode-snippetmyqrcolorizedimage overlay
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.