我目前正在 Windows 10 上通过 anaconda 使用spyder 和 python 3.8.5,并且我正在尝试使用 pyzbar 包来制作条形码读取器。当我尝试运行脚本时,我在尝试运行
from pyzbar.pyzbar import decode
和 from pyzbar import pyzbar
: 时收到此错误消息
Traceback (most recent call last):
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 58, in load
dependencies, libzbar = load_objects(Path(''))
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp>
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 459, in LoadLibrary
return self._dlltype(name)
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<ipython-input-1-95ae0761f4b5>", line 1, in <module>
from pyzbar.pyzbar import decode
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\pyzbar.py", line 7, in <module>
from .wrapper import (
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 139, in <module>
zbar_version = zbar_function(
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 136, in zbar_function
return prototype((fname, load_libzbar()))
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 115, in load_libzbar
libzbar, dependencies = zbar_library.load()
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 60, in load
dependencies, libzbar = load_objects(Path(__file__).parent)
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp>
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 459, in LoadLibrary
return self._dlltype(name)
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
当尝试运行
import pyzbar
时,它将编译,但无法访问任何函数。当我尝试时,我收到此消息:
Traceback (most recent call last):
File "<ipython-input-3-26272af93b8a>", line 1, in <module>
pyzbar.pyzbar.decode()
AttributeError: module 'pyzbar' has no attribute 'pyzbar'
我在 github 上查找了 pyzbar 的文档,其中指出“Zbar DLL 包含在 Windows Python 轮子中”,但在任何地方都没有找到。我发现的最接近“Windows Python 轮子”的是轮子包,它不包含有关 pyzbar 的任何信息。
关于如何解决这个问题有什么建议吗?
访问 https://pypi.org/project/pyzbar/#files 下载 pyzbar-0.1.8-py2.py3-none-win_amd64.whl。
您可以在wheel包中找到所有DLL文件。
我刚刚遇到这个问题。 如果您的操作系统和 python 是 x64 版本,那只是因为缺少 vc 2013 x64 运行时。
Visual C++ Redistributable Packages for Visual Studio 2013
下载并安装。
我刚刚安装 Visual 时遇到了类似的问题 我的计算机上的 C++ 64 位版本并重新启动。根据您的计算机选择 vcredist_x86.exe 或 vcredist_x64.exe。
https://www.microsoft.com/en-us/download/confirmation.aspx?id=40784。希望这也能解决您的问题。
请安装 Windows 错误消息 如果您在 Windows 上导入 pyzbar 时看到丑陋的 ImportError,您很可能需要 Visual Studio 2013 的 Visual C++ Redistributable Packages。如果使用 64 位 Python,请安装 vcredist_x64.exe;如果使用 32 位 Python,请安装 vcredist_x86.exe。
点击下面的链接...(转到出现的网页的bootom)并安装它...
https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170