I need to install a module pyzbar which depends on another called zbar. According to the pypi link I first need to install zbar via
brew install zbar
then install the pyzbar
pip install pyzbar
Having done of that when trying to run a code based on importing specific part of the module, it gives an error.
from pyzbar.pyzbar import decode
The error is ImportError: Unable to find zbar shared library
How to check where exactly is the issue coming from and how to resolve it?
Here are steps I took after checking comments: 1- Tried finding libzbar file and some how link that to the path so that the pyzbar file zbar_library.py can find that. The libzbar files were in this location /opt/homebrew/Cellar/zbar/0.23.90 installed by homebrew and not in usr/local/lib (which surprisingly no such directory exists on my mac). The way I added the location of zbar lib file to path was by
export DYLD_LIBRARY_PATH=/opt/homebrew/lib
in the terminal while I'm in the conda environment on which my python is running. Now when trying to run python while importing pyzbar it finds something and no longer give the "no shared lib found" error, but gives the following errors:
File "/Users/username/miniconda3/envs/my_env/lib/python3.7/site-packages/pyzbar/zbar_library.py", line 66, in load
libzbar = cdll.LoadLibrary(path)
File "/Users/username/miniconda3/envs/my_env/lib/python3.7/ctypes/__init__.py", line 442, in LoadLibrary
return self._dlltype(name)
File "/Users/username/miniconda3/envs/my_env/lib/python3.7/ctypes/__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/opt/homebrew/lib/libzbar.dylib, 6): no suitable image found. Did find:
/opt/homebrew/lib/libzbar.dylib: mach-o, but wrong architecture
/opt/homebrew/Cellar/zbar/0.23.90/lib/libzbar.0.dylib: mach-o, but wrong architecture
/opt/homebrew/lib/libzbar.dylib: mach-o, but wrong architecture
/opt/homebrew/Cellar/zbar/0.23.90/lib/libzbar.0.dylib: mach-o, but wrong architecture
You may have multiple python/pip versions that caused such issue. To be sure about this, you can try
python3.9 -m pip install pyzbar
python3.9
from pyzbar.pyzbar import decode
If there are still any errors on import, please include a list of all installed pip packages by doing
pip freeze --all
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With