Python: To generate a qrcode

Python: To generate a qrcode

There are a lot of options where you can generate a qrcode.

What is a QRcode?

The QRcode is the little black-white box where you can save data. In most cases, this is the URL of a website.

What is the URL?

The URL identifies and locates a resource on the Internet or on a local network (e.g. a web page, an image, a file or an email address).

What is Python?

Python is a programming language. In the meanwhile, it is an all-round „service“ where you can do a lot of things for example for your computer, for the web, to change pictures, data science → artificial intelligence (machine learning) and many more.

It is an easy language where you create your code and can run directly.

To install the module QR-Code

In Python, you can install several modules, in order to do a lot of tasks very easy. The modules are written in another programming language. C is the programming language. C is an old programming language that was invented in 1972.

In order to generate a qrcode you have to install the python programming language. In the Linux distributions, Python is mostly installed by default and has the newest version. The exceptions are the Long-Term distribution like Debian or AlmaLinux for example.

Windows users go to the official web page of Python and download there the package.

Mac user go to the official web page of Python and download it here, too, or go to your terminal and type in

The current version of Python is 3.13.7 (29.09.2025)

Once you have installed Python, then you have to install the QR-Code module with:

The current version of the qrcode module is 8.2

In order to update your python modules, you type in the command prompt:

(then it will show whether there is new version) and if there is a new version then you have to type in the command prompt:

The script for the QR-code

import qrcode

qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)
qr.add_data("https://sven-essen.de")
qr.make(fit=True)

img = qr.make_image(fill_color="black", back_color="white")

img.save("versuchen.png")
Die Kommentare sind geschlossen.