5

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.

Nano Taboada
  • 4,148
  • 11
  • 61
  • 89
Michael Franzen
  • 445
  • 3
  • 11

1 Answers1

6

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)
Eryk Sun
  • 33,190
  • 5
  • 92
  • 111
  • @DrBwts, you'll have to do the work to solve it yourself. Use dumpbin to verify the dependencies of zbar.pyd. Verify that `os.listdir(os.path.join(os.environ['ProgramFiles'], 'zbar', 'bin'))` contains the dependent zbar DLL, e.g. libzbar-0.dll. Investigate the dependencies of the dependent DLLs, and so on. Learn to use a native debugger (not Python -- something like windbg or cdb) and walk through the import with loader snaps enabled. – Eryk Sun Jan 21 '19 at 16:41