Tag Archives: QR Code

QR Code: in Python

libpng12-0
libpng12-dev
pkg-config

Install libqrencode
http://fukuchi.org/works/qrencode/index.en.html
Libqrencode is a C library for encoding data in a QR Code symbol, a kind of 2D symbology that can be scanned by handy terminals such as a mobile phone with CCD. The capacity of QR Code is up to 7000 digits or 4000 characters, and is highly robust.
Download: http://fukuchi.org/works/qrencode/qrencode-3.1.1.tar.gz

Compile & install
./configure
make
make install

Usage
qrencode -h

Install pyqrencode
http://github.com/bitly/pyqrencode
Python bindings for libqrencode

Download
http://github.com/bitly/pyqrencode/archives/master

Install
python setup.py install

Usage
python test_qr.py

Problem
$ python test_qr.py
Traceback (most recent call last):
File “test_qr.py”, line 1, in <module>
from qrencode import Encoder
ImportError: libqrencode.so.3: cannot open shared object file: No such file or directory
Solution
$ export LD_LIBRARY_PATH=/usr/local/lib

QR Code: in Python

pyqrcode
Project site at: http://pyqrcode.sourceforge.net/
Download source code: http://downloads.sourceforge.net/pyqrcode/pyqrcode-0.2.1.tar.gz?use_mirror=
Install from sourcecode on Ubuntu 10.04

$ sudo apt-get install jcc sun-openjdk-6-jdk python-imaging python-setuptools python-dev
For Python 2.6
replace “-m jcc” with “-m jcc.__main__” in Makefile
make
sudo make install

code example

#!/usr/bin/env python
# coding: utf-8
#
# pyqrcode sample encoder
 
import sys, qrcode
 
e = qrcode.Encoder()
image = e.encode('woah!', version=15, mode=e.mode.BINARY, eclevel=e.eclevel.H)
image.save('out.png')

There is a error like this.
Traceback (most recent call last):
File “sample1.py”, line 6, in <module>
import sys, qrcode
File “/usr/local/lib/python2.6/dist-packages/qrcode-0.2.1-py2.6-linux-i686.egg/qrcode/__init__.py”, line 21, in <module>
_qrcode._setExceptionTypes(JavaError, InvalidArgsError)
AttributeError: ‘module’ object has no attribute ‘_setExceptionTypes’