I am working on a Mac OSX 10.13.6 and trying to build a barcode reader using python3. Unfortunately, I can not even import the decode module in the pyzbar package. I have tried installing zbar, libzbar0, zbarlight, etc. and all attempts fail
Here are my successful installations
$ pip3 install pyzbar
Requirement already satisfied: pyzbar in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (0.1.8)
$ pip3 install opencv-python
Requirement already satisfied: opencv-python in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (4.1.1.26)
Requirement already satisfied: numpy>=1.14.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from opencv-python) (1.16.2)
Here is the failure message when I try to use my successfully installed pyzbar package to import a decode function despite the face that I know pyzbar has a decode function:
>>> from pyzbar.pyzbar import decode
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyzbar/pyzbar.py", line 7, in <module>
from .wrapper import (
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyzbar/wrapper.py", line 143, in <module>
c_uint_p, # minor
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyzbar/wrapper.py", line 136, in zbar_function
return prototype((fname, load_libzbar()))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyzbar/wrapper.py", line 115, in load_libzbar
libzbar, dependencies = zbar_library.load()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyzbar/zbar_library.py", line 65, in load
raise ImportError('Unable to find zbar shared library')
ImportError: Unable to find zbar shared library
When I tried to install zbar, this is what occurred:
$ pip3 install zbar
Collecting zbar
Using cached https://files.pythonhosted.org/packages/33/54/cc5819efc9ee7e34b60b41e1d2d4753b6dd0c26a41c9a552611f66aa106e/zbar-0.10.tar.bz2
Building wheels for collected packages: zbar
Building wheel for zbar (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-install-rhbz3vss/zbar/setup.py'"'"'; __file__='"'"'/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-install-rhbz3vss/zbar/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-wheel-z0xoqwir --python-tag cp37
cwd: /private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-install-rhbz3vss/zbar/
Complete output (13 lines):
running bdist_wheel
running build
running build_ext
building 'zbar' extension
creating build
creating build/temp.macosx-10.9-x86_64-3.7
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c zbarmodule.c -o build/temp.macosx-10.9-x86_64-3.7/zbarmodule.o
In file included from zbarmodule.c:24:
./zbarmodule.h:26:10: fatal error: 'zbar.h' file not found
#include <zbar.h>
^~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for zbar
Running setup.py clean for zbar
Failed to build zbar
Installing collected packages: zbar
Running setup.py install for zbar ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-install-rhbz3vss/zbar/setup.py'"'"'; __file__='"'"'/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-install-rhbz3vss/zbar/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-record-5zw82lo9/install-record.txt --single-version-externally-managed --compile
cwd: /private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-install-rhbz3vss/zbar/
Complete output (13 lines):
running install
running build
running build_ext
building 'zbar' extension
creating build
creating build/temp.macosx-10.9-x86_64-3.7
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c zbarmodule.c -o build/temp.macosx-10.9-x86_64-3.7/zbarmodule.o
In file included from zbarmodule.c:24:
./zbarmodule.h:26:10: fatal error: 'zbar.h' file not found
#include <zbar.h>
^~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-install-rhbz3vss/zbar/setup.py'"'"'; __file__='"'"'/private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-install-rhbz3vss/zbar/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/74/01qhmy3s3qg_fwctkdf6mrvh0000gn/T/pip-record-5zw82lo9/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
So then went to https://pypi.org/project/pyzbar/ and read that "The zbar DLLs are included with the Windows Python wheels. On other operating systems, you will need to install the zbar shared library." The site then gives an option to use brew install zbar or pip install pyzbar.
Because I do not want to install homebrew, I used pip install pyzbar.
It did not help. Any advice on getting this to work?