Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to generate barcode in python 3.7

I am using python 3.7, for barcode generation I am trying to install pyBarcode library using pip install pyBarcode'. but it shows the following error:

Could not find a version that satisfies the requirement pyBarcode (from versions: ) no matching distribution found for pyBarcode

Now, how can I install pyBarcode for my Python version?

like image 406
mitul rana Avatar asked Sep 01 '25 03:09

mitul rana


1 Answers

1st install the right lib:

pip install python-barcode

then code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import barcode
from barcode.writer import ImageWriter

def testEan():
    EAN = barcode.get_barcode_class('ean13')
    ean = EAN(u'123456789011', writer=ImageWriter())
    fullname = ean.save('my_ean13_barcode')

if __name__ == '__main__':
    testEan()

this code produces

enter image description here

like image 191
ΦXocę 웃 Пepeúpa ツ Avatar answered Sep 02 '25 16:09

ΦXocę 웃 Пepeúpa ツ