libdmtx Python Wrapper

1. libdmtx Installation

libdmtx must be installed on your system before trying to install and run the Python wrapper. Refer to the General Instructions for this.

2. pydmtx Installation

At the moment (version 0.7.4) the wrappers are not released as a package on the sourceforge page (

Get dmtx-wrappers from

$ git clone git://

After libdmtx is present, next install pydmtx by running the following command as root:

$ python install

Once installed, you can verify it works by running as yourself:

$ python

3. Troubleshooting

3.1. ImportError: cannot open shared object file

This error indicates it is not able to find the libdmtx library. There are a few ways to fix this. You can make a temporary local session fix:

$ export LD_LIBRARY_PATH=/usr/local/lib

… or make a permanent fix that requires root privileges:

$ /sbin/ldconfig /usr/local/lib

Alternatively, you could edit /etc/ to include /usr/local/lib (which also requires root privileges).

When it is working properly the script should create an image named 'hello.png' in the current directory. The image should be a Data Matrix barcode that scans to "hello, world".

3.2. SystemError: NULL result without error in PyObject_Call

Could mean that you're passing in a 1 bit b/w image instead of a RGB image. This is a good guard against that.

img = f )
if img.mode != 'RGB':
   img = img.convert('RGB')
print dm_read.decode( img.size[0], img.size[1], buffer(img.tostring()) )

4. Dependencies

These packages are required to install and run pydmtx:

If you are using an RPM-based system then you can test for the following packages:

  • python
  • python-devel
  • python-imaging

5. Anything Else?

Is something missing from these instructions? If you spent hours searching for a solution that you feel should be included here then please update this page directly.

[Add your documentation here…]

6. This Document

Updates to this page ultimate feed into the wrapper/python/README file that is distributed with the source package. If you are looking for information specific to an older release, please refer to this file as it exists in that package version.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License