Build your own QRCode using Python

Ayush Srivastava
3 min readMar 18, 2022

A qrcode or called as Quick Response Codes are kind of hyperlinks. They contain information that after scanning redirects you to a location, website or an application. These days qrcodes are became so popular due to its fast readability and greater storage capacity.

Today we will learn about how to create your own QR Code using Python which redirects you to given website or link.

So let’s start 👍

First we have to install two libraries in our IDE -> pyqrcode and pypng.

So let’s install our first library.

  • Open Pycharm IDE and create a new Project with the name QRCodeGenerator.
  • Under the project, create a Python file with the name QrCode.py
  • Open the terminal and enter command pip install pyqrcode.
Installing pyqrcode library

Here in the above image, we can see that pyqrcode successfully installed.

  • Now install second library pypng.
Installing pypng library

Here in the above image, we can see that pypng successfully installed.

  • We have successfully installed both the libraries now we have to import them in our main python file.
  • For importing both the libraries, use import method.
Importing python libraries
  • Here we have imported QRCode from pyqrcode library.
  • Enter the URL through it will redirect you after scanning.
  • In my case I have used my Linkedin profile url. In your case you can customize it accordingly.
My Linkedin Profile URL
  • In above image, I have stored url into “site” variable.
  • Create the qrcode which redirects you to this url.
Creating and saving Qrcode
  • Using pyqrcode.create(), we are creating the url of the given site and storing it as “MyProfile.png”(using Pypng module).
  • Using url.show(), the qrcode will display and we can scan it.
  • Final step, click on Run button.
QrCode
  • Using any QRCode scanner when you scan it will redirects you to my Linkedin Profile.

Conclusion:

In this tutorial we have learnt that how to build your own QrCode using Python. First we installed and imported two libraries pyqrcode and pypng. Then entered the URL on which qrcode redirects you after scanning. Finally we have scanned the qrcode using any qr code scanner.

Thanks for the reading to the end. Hope you enjoyed this article . 😊

Please click on the clap button, comment and share it for more amazing topics.

--

--