How to create Barcodes in python

What is a Barcode?

barcode is an optical, machine-readable , representation of data , the data usually describes something about the object that carries the barcode . Traditional barcodes systematically represent data by varying the widths and spacings of parallel lines, and may be referred to as linear or one-dimensional (1D) ,we can quickly test on console (mac, tested on ubuntu , debian).

PyBarcode ships with a little commandline script to generate barcodes without knowing Python. The install script detects your Python version and adds the major version number to the executable script. On Python 2 it is called pybarcode2 and on Python 3 pybarcode3. When installing in a systemwide direction, you can have pyBarcode installed in Python 2 and 3 at the same time without trouble.


  • Setuptools/distribute for installation (new in version 0.7beta4)
  • Python 2.6 or above (including Python 3.x)
  • On Python 2.6, 3.0, 3.1: argparse (for the commandline script)
  • Program to open SVG objects (your browser should do it)
  • Optional: PIL to render barcodes as images (PNG, JPG, …)


Make sure you have setuptools/distribute installed.

Unpack the downloaded file, cd into the pyBarcode directory and run python install. Or just copy the barcode dir somewhere in your PYTHONPATH.

The best way is to use pip:

pip install pyBarcode

Provided Barcodes

EAN-8, EAN-13, UPC-A, JAN, ISBN-10, ISBN-13, ISSN, Code 39, PZN


Usage form command line

pybarcode{2,3} create “My Text” barcodename

If you know which python version your system have then run accordingly.I am assuming python3.x

pybarcode{2,3} create -t png "My Text" outfile


pybarcode3 create "My Text" outfile


Sample example to generate QR code and save in svg file in python.


ean13 is EAN or European Article Number and 13 representing it is 13 digit number

>>> import barcode
>>> ean = barcode.get('ean13', '123456789102')
# Now we look if the checksum was added
>>> ean.get_fullcode()
>>> filename ='ean13')
>>> filename
>>> options = dict(compress=True)
>>> filename ='ean13', options)
>>> filename

Now we have ean13.svg and the compressed ean13.svgz in our current working directory. Open it and see the result.


To generate barcodes as images, you must provide the ImageWriter to the get function. Without any options, the images are rendered as PNG.

>>> import barcode
>>> from barcode.writer import ImageWriter
>>> ean = barcode.get('ean13', '123456789102', writer=ImageWriter())
>>> filename ='ean13')
>>> filename


source :

join our python training in kanpur for Zero to Hero in Python.

How to create QR code in Python

What is a QR Code in nutshell?

A Quick Response code is a two-dimensional pictographic code used for its fast readability and comparatively large storage capacity. The code consists of black modules arranged in a square pattern on a white background. The information encoded can be made up of any kind of data (e.g., binary, alphanumeric)

its very simple on console (tested on mac, debian and ubuntu latest OS)

below command will install all required module including pil (Python Imaging Library):pillow

pip install qrcode[pil]


Usage form command line

qr "Some text" > image_name_with_extention
qr "" > msk.png


Sample example to generate QR code and save in png file in python.

import qrcode
qr = qrcode.QRCode(


img = qr.make_image(fill_color="black", back_color="white")'msk-site.png') 

Sample example to instant preview of QR code in python.

import qrcode
qr = qrcode.QRCode(
qr.add_data('Some data')

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


source :

join our python training in kanpur for Zero to Hero in Python.

Visualization of DataSet is fun in Orange


Visualizing Data Set is fun using Orange


Data has become powerful source of earning and predict future and people will seek to utilize it even if they don’t know exactly how. Machine learning will become a usual part of programmer’s resume, data scientists will be as common as accountants. Now a days and for the next approximately two decades, we will continue to see a major need for machine learning and data science specialists to help apply machine learning technologies to application areas where they aren’t applied today.

Now a day people prefer GUI based tools instead of more coding stuffs . Orange is one of the popular open source machine learning and data visualization tool for beginners. People who don’t know more about coding and willing to visualize pattern and other stuffs can easily work with Orange.

Why Orange:

Orange is an open-source software package released under GPL that powers Python scripts with its rich compilation of mining and machine learning algorithms for data pre-processing, classification, modelling, regression, clustering and other miscellaneous functions.

Orange also comes with a visual programming environment and its workbench consists of tools for importing data, and dragging and dropping widgets and links to connect different widgets for completing the workflow.

Orange uses common Python open-source libraries for scientific computing, such as numpy, scipy and scikit-learn, while its graphical user interface operates within the cross-platform Qt framework.


Getting Started:

Download Orange

=> Go to and click on Download.

For Linux Users:


If you are using python provided by Anaconda distribution, you are almost ready to go . If not, follow these steps to download Orange :

conda config –add channels conda-forge

and run

conda install orange3
conda install -c defaults pyqt=5 qt


Orange can also be installed from the Python Package Index. You may need additional system packages provided by your distribution.

pip install orange3

Run short code to verify you setup Orange successfully. Open your Python Terminal and run the following code :

 import Orange

Note: If You find result shown above then you successfully setup Orange. In case you get error like this

from import _variable
ImportError: cannot import name '_variable'


Kindly Follow These Steps : Install Orange From Source

Mac and Windows user can easy setup orange in their system step by step just follow official docs of Orange:

Official docs for setup Orange

After installation let’s start working with Orange

Visualization of Data Set in Orange:

A primary goal of data visualization is to communicate information clearly and efficiently via statistical graphics, plots and information graphics.

“Main goal of data visualization is to communicate information clearly and effectively through graphical means. It doesn’t mean that data visualization needs to look boring to be functional or extremely sophisticated to look beautiful. To convey ideas effectively, both aesthetic form and functionality need to go hand in hand, providing insights into a rather sparse and complex data set by communicating its key-aspects in a more intuitive way. Yet designers often fail to achieve a balance between form and function, creating gorgeous data visualizations which fail to serve their main purpose — to communicate information.”
-Friedman (2008)

Open Orange on your system & create your own new Workflow:

After you clicked on “New” in the above step, this is what you should have come up with:

In this tutorial we are going to learn Visualization of Data Set in few steps as given below:

Step 1: Without data there is no existence of Machine Learning. So In our first step we import our data set in this tutorial I uses example data set available in Orange Directory.
We import data set in file widget.

Step 2: In next step we need data tables to viewing our data set. For this we use Data Table widget.

When we double click on the data table widget we can visualize our data in actual format :

Step 3: This is the last step where we will understand our data, with the help of visualization. Orange make visualization pretty much easier. We just add one more widget and choose in which format we would like to visualize our data like Scatter Plot.

This completely works on the concept of neurons, data transfer from one layer to other layer when we connect data table to scatter plot widget then we find actual representation of our data in the form of scatter plot.

Closing Note:

Orange is most powerful tool used for almost any kind of analysis and visualization of data. The default installation includes a number of machine learning, preprocessing and data visualization algorithms in 6 widget sets (data, visualize, classify, regression, evaluate and unsupervised). Additional functionalities are available as add-ons (bio-informatics, data fusion and text-mining).

Hope this tutorial help you to understand data visualization with the help of Orange. It is very important to understand the flow of data, this helps you to figure out problems easily.

Keep Practice with Orange

Happy Coding!