Fundamentals 5 min read

Create Custom QR Codes in Python with MyQR – A Step‑by‑Step Guide

This tutorial walks you through installing the MyQR library, importing it in PyCharm, and generating plain, image‑based, and colored QR codes with Python, while also providing a full list of configurable parameters for advanced customization.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Create Custom QR Codes in Python with MyQR – A Step‑by‑Step Guide

1. Install MyQR library

Open the command prompt (Windows+R, then type cmd) and run: pip install myqr Wait until the installation completes successfully.

2. Import MyQR in PyCharm

In PyCharm go to File → Settings → Python Interpreter , click the + button, search for MyQR, select the first result and click Install Package . After installation you can import the library in your code:

from MyQR import myqr

3. Generate a plain QR code

Use the following code to create a simple QR code that encodes a URL or text: myqr.run(words='https://baidu.com') The generated file qrcode.png will appear in the same directory as your script.

4. Generate a QR code with a custom picture

Add the picture argument to embed an image into the QR code:

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

5. Generate a colored QR code

Set colorized=True to produce a colored QR code (requires a custom picture as well):

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

6. Extended parameters

MyQR offers many additional options for fine‑tuning the output. Below is a comprehensive example:

myqr.run(
    words='https://example.com',
    version=5,               # error correction level
    level='H',                # L, M, Q, H (increasing redundancy)
    picture='logo.png',       # path to an image (can be GIF)
    colorized=True,           # True for color, False for black‑white
    contrast=1.0,             # image contrast
    brightness=1.0,          # image brightness
    save_name='custom_qr.png',
    save_dir=r'C:\Users'
)

These parameters let you control the QR code size, error correction, embedded image, colorization, contrast, brightness, and output location.

Installation screenshot
Installation screenshot
PyCharm package manager
PyCharm package manager
Add MyQR package
Add MyQR package
Installation progress
Installation progress
Generated QR code file
Generated QR code file
QR code displayed in folder
QR code displayed in folder
Custom picture QR code
Custom picture QR code
Colored QR code
Colored QR code
Parameter list screenshot
Parameter list screenshot
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.

Code GenerationTutorialQR codemyqr
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

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.