Я работаю над Mac OSX 10.13.6
и пытаюсь построить считыватель штрих-кода, используя python3
. К сожалению, я даже не могу импортировать модуль декодирования в пакет pyzbar
. Я попытался установить zbar
, libzbar0
, zbarlight
и т. Д., И все попытки потерпели неудачу
Вот мои успешные установки
$ 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)
Вот сообщение об ошибке при попыткеиспользовать мой успешно установленный пакет pyzbar
для импорта функции decode
, несмотря на то, что я знаю, что pyzbar имеет функцию декодирования:
>>> 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
Когда я пытался установить zbar
, это произошло:
$ 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.
Итак, перейдите к https://pypi.org/project/pyzbar/ и прочитайте, что «DLL-библиотеки zbar включены в колеса Windows Python. В других операционных системах вам потребуется установить общую библиотеку zbar. "Затем сайт дает возможность использовать brew install zbar
или pip install pyzbar
.
Поскольку я не хочу устанавливать homebrew
, я использовал pip install pyzbar
.
Это не помогло. Любой совет, как заставить это работать?