Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python26, Win32, ZBar - ImportError: DLL load failed

Tags:

python

I am using Python 2.6 (x86) and tried to install the ZBar module.

I downloaded the current version of ZBar (Win32-Installer): http://zbar.sourceforge.net/download.html

and the current version of the module on PyPi: http://pypi.python.org/pypi/zbar

ZBar (prompt and webcam) works fine but as soon as I try to import zbar in Python, the following error raises:

import zbar
ImportError: DLL load failed

This happens when I try it with the binary windows installer of the module but I also tried using the setup.py which always exits with:

running install
running build
running build_ext
building 'zbar' extension
error: None

Thank you, Michael

EDIT: I also tried to troubleshoot the Lib/site-packages/zbar.pyd with Dependency Walker and it raised libzbar-0.dll and python26.dll to be missing.

like image 674
Michael Franzen Avatar asked Oct 15 '11 02:10

Michael Franzen


1 Answers

Add the path to libzbar-0.dll to your system PATH so Windows can find it when zbar.pyd is loaded.

Edit: I installed the application and Python library. Here's how to make it work without changing your PATH through the control panel system configuration:

>>> zbar_path = os.path.join(os.environ['ProgramFiles'], 'zbar', 'bin')
>>> os.environ['PATH'] = "{0};{1}".format(os.environ['PATH'], zbar_path)

>>> import zbar
>>> zbar.version()
(0, 10)
like image 111
Eryk Sun Avatar answered Nov 14 '22 12:11

Eryk Sun