You can try the following steps and code using qrtools:
-
Create a
qrcodefile, if not already existing- I used
pyqrcodefor doing this, which can be installed usingpip install pyqrcode -
And then use the code:
>>> import pyqrcode >>> qr = pyqrcode.create("HORN O.K. PLEASE.") >>> qr.png("horn.png", scale=6)
- I used
-
Decode an existing
qrcodefile usingqrtools- Install
qrtoolsusingsudo apt-get install python-qrtools -
Now use the following code within your python prompt
>>> import qrtools >>> qr = qrtools.QR() >>> qr.decode("horn.png") >>> print qr.data u'HORN O.K. PLEASE.'
- Install
Here is the complete code in a single run:
In [2]: import pyqrcode
In [3]: qr = pyqrcode.create("HORN O.K. PLEASE.")
In [4]: qr.png("horn.png", scale=6)
In [5]: import qrtools
In [6]: qr = qrtools.QR()
In [7]: qr.decode("horn.png")
Out[7]: True
In [8]: print qr.data
HORN O.K. PLEASE.
Caveats
- You might need to install
PyPNGusingpip install pypngfor usingpyqrcode -
In case you have
PILinstalled, you might getIOError: decoder zip not available. In that case, try uninstalling and reinstallingPILusing:pip uninstall PIL pip install PIL -
If that doesn’t work, try using
Pillowinsteadpip uninstall PIL pip install pillow