How to generate barcode using python

Step by step guide with github code

Abhijith Chandradas
3 min readAug 25, 2024

Prerequisites

Generating barcode in python requires the following libraries to be installed.

Barcode is used to encode the data into the required type of barcode. Pillow is an image processing package used to save and view the barcodes generated.

These libraries can be installed as below.

pip install python-barcode 
pip install pillow

Supported Barcode Types

The following command can be used to view the supported barcode formats by Barcode library.

import barcode
print(barcode.PROVIDED_BARCODES)

The following types of barcode formats are currently supported

'codabar', 'code128', 'code39', 'ean', 'ean13', 'ean13-guard', 'ean14', 'ean8', 'ean8-guard', 'gs1', 'gs1_128', 'gtin', 'isbn', 'isbn10', 'isbn13', 'issn', 'itf', 'jan', 'nw-7', 'pzn', 'upc', 'upca'

More details on each format — area of application, specifications, schema etc. can be found online.

Generate Barcode of specific type

In this example we use EAN14 format of barcode. EAN14 is used for traded goods.
EAN14 format encodes a 13 digit number and adds a check digit at the end calculated using Modulo 10 algorithm.
The…

--

--

Abhijith Chandradas
Abhijith Chandradas

Written by Abhijith Chandradas

Data Analyst | Hacker | Financial Analyst | Freelancer | IIM MBA | Opensource | Democratize Knowledge | https://www.youtube.com/channel/UCLpBd4gzfIBXm2BPpdHOWdQ

No responses yet