Michael Franzen
Michael Franzen

Reputation: 425

Python26, Win32, ZBar - ImportError: DLL load failed

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.

Upvotes: 5

Views: 2947

Answers (1)

Eryk Sun
Eryk Sun

Reputation: 34280

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)

Upvotes: 6

Related Questions