Harbola DataScience

Answer, Read and Post Coding related Questions!

Barcode Using Python barcode EAN13

Fun code that will convert 12 digit number to a barcode which you can scan using barcode reader. If you don’t want to tell number or it is secret or something like that. You can use this. Also there are many other Real world uses cases of barcode. SO you can create your own barcode generator using python barcode library.

The International Article Number (also known as European Article Number or EAN) is a standard describing a barcode symbology and numbering system used in global trade to identify a specific retail product type. know more about this.

Demonstration of generating barcode using python barcode EAN13

barcode named png file will be created to your relative path when you run this code.

Implementation of barcode generator using python barcode EAN13

Before you create your python file keep in mind that you don’t name your file barcode because it will pass error. something like partially initiailised module named “barcode”

Importing barcode and ImageWriter for barcode generation

If you don’t have barcode installed. Using pip command install it first.

Creating a EAN13 Object and Saving barcode image file

You can pass any 12 digit number inside ‘number’ and pass it inside EAN13 to create a my_code object. To save your image file use .save() command.

Soon we will also create a barcode reader.


If you face any error in implementing this or have any query, feel free to contact or dm me @chitranshuharbola@gmail.com

Chitranshu Harbola

Self taught programmer, Web Developer and an aspiring Machine learning engineer cum Data Science student

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top