-
Notifications
You must be signed in to change notification settings - Fork 189
Description
CHECK THE BOLD MESSAGES
I don't know if this is a common prob to everyone and if this will be the longest Issue ever but I'll try to make it short but still providing the error and the codes:
The Error:
Traceback (most recent call last): File "d:\OneDrive - De La Salle Santiago Zobel School, Inc\Desktop\FLL\app.py", line 3, in <module> from pyzbar.pyzbar import decode File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\pyzbar.py", line 7, in <module> from .wrapper import ( File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\wrapper.py", line 151, in <module> zbar_version = zbar_function( File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\wrapper.py", line 148, in zbar_function return prototype((fname, load_libzbar())) File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\wrapper.py", line 127, in load_libzbar libzbar, dependencies = zbar_library.load() File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\zbar_library.py", line 61, in load dependencies, libzbar = load_objects(dll_path.parent) File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\zbar_library.py", line 50, in load_objects deps = [ File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp> cdll.LoadLibrary(str(directory.joinpath(dep))) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 452, in LoadLibrary return self._dlltype(name) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 374, 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.
It's literally told there that the problem is libiconv.dll. I will not show my project because it's literally obvious what the problem was. And yes, the file is not in the incorrect path nor corrupted.
This is the unedited code code from zbar_library.py:
`"""Loads zbar and its dependencies.
"""
import platform
import sys
from ctypes import cdll
from ctypes.util import find_library
from pathlib import Path
all = ['load']
def _windows_fnames():
"""For convenience during development and to aid debugging, the DLL names
are specific to the bit depth of interpreter.
This logic has its own function to make testing easier
"""
# 'libzbar-64.dll' and 'libzbar-32.dll' each have a dependent DLL -
# 'libiconv.dll' and 'libiconv-2.dll' respectively.
if sys.maxsize > 2**32:
# 64-bit
fname = 'libzbar-64.dll'
dependencies = ['libiconv.dll']
else:
# 32-bit
fname = 'libzbar-32.dll'
dependencies = ['libiconv-2.dll']
return fname, dependencies
def load():
"""Loads the libzar shared library and its dependencies.
"""
if 'Windows' == platform.system():
# Possible scenarios here
# 1. Run from source, DLLs are in pyzbar directory
# cdll.LoadLibrary() imports DLLs in repo root directory
# 2. Wheel install into CPython installation
# cdll.LoadLibrary() imports DLLs in package directory
# 3. Wheel install into virtualenv
# cdll.LoadLibrary() imports DLLs in package directory
# 4. Frozen
# cdll.LoadLibrary() imports DLLs alongside executable
fname, dependencies = _windows_fnames()
def load_objects(directory):
# Load dependencies before loading libzbar dll
deps = [
cdll.LoadLibrary(str(directory.joinpath(dep)))
for dep in dependencies
]
libzbar = cdll.LoadLibrary(str(directory.joinpath(fname)))
return deps, libzbar
dll_path = Path(r'C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\libzbar-64.dll')
try:
dependencies, libzbar = load_objects(Path(''))
except OSError:
dependencies, libzbar = load_objects(Path(__file__).parent)
else:
# Assume a shared library on the path
path = find_library('zbar')
if not path:
raise ImportError('Unable to find zbar shared library')
libzbar = cdll.LoadLibrary(path)
dependencies = []
return libzbar, dependencies`
And this is what I edited in the code:
`"""Loads zbar and its dependencies.
"""
import platform
import sys
from ctypes import cdll
from ctypes.util import find_library
from pathlib import Path
all = ['load']
def _windows_fnames():
"""For convenience during development and to aid debugging, the DLL names
are specific to the bit depth of interpreter.
This logic has its own function to make testing easier
"""
# 'libzbar-64.dll' and 'libzbar-32.dll' each have a dependent DLL -
# 'libiconv.dll' and 'libiconv-2.dll' respectively.
if sys.maxsize > 2**32:
# 64-bit
fname = 'libzbar-64.dll'
dependencies = ['libiconv.dll']
else:
# 32-bit
fname = 'libzbar-32.dll'
dependencies = ['libiconv-2.dll']
return fname, dependencies
def load():
"""Loads the libzar shared library and its dependencies.
"""
if 'Windows' == platform.system():
# Possible scenarios here
# 1. Run from source, DLLs are in pyzbar directory
# cdll.LoadLibrary() imports DLLs in repo root directory
# 2. Wheel install into CPython installation
# cdll.LoadLibrary() imports DLLs in package directory
# 3. Wheel install into virtualenv
# cdll.LoadLibrary() imports DLLs in package directory
# 4. Frozen
# cdll.LoadLibrary() imports DLLs alongside executable
fname, dependencies = _windows_fnames()
def load_objects(directory):
# Load dependencies before loading libzbar dll
deps = [
cdll.LoadLibrary(str(directory.joinpath(dep)))
for dep in dependencies
]
libzbar = cdll.LoadLibrary(str(directory.joinpath(fname)))
return deps, libzbar
_//Just added this because I was told to in the error_
dll_path = Path(r'C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\libzbar-64.dll')
try:
dependencies, libzbar = load_objects(dll_path)
except OSError:
dependencies, libzbar = load_objects(dll_path.parent)
else:
# Assume a shared library on the path
path = find_library('zbar')
if not path:
raise ImportError('Unable to find zbar shared library')
libzbar = cdll.LoadLibrary(path)
dependencies = []
return libzbar, dependencies
`
This is what error I got now from editing line 59 and 61:
Traceback (most recent call last):
File "d:\OneDrive - De La Salle Santiago Zobel School, Inc\Desktop\FLL\app.py", line 3, in
from pyzbar.pyzbar import decode
File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\pyzbar.py", line 7, in
from .wrapper import (
File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\wrapper.py", line 151, in
zbar_version = zbar_function(
File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\wrapper.py", line 148, in zbar_function
return prototype((fname, load_libzbar()))
File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\wrapper.py", line 127, in load_libzbar
libzbar, dependencies = zbar_library.load()
File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\zbar_library.py", line 61, in load
dependencies, libzbar = load_objects(dll_path.parent)
File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\zbar_library.py", line 51, in
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\ctypes_init_.py", line 452, in LoadLibrary
return self.dlltype(name)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\ctypes_init.py", line 374, in init
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\zande\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pyzbar\libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Almost the same but I change the code with the constructor syntax now. I have been researching from here in github, in other websites, and still didn't find anything to fix this. Can someone from the devs help me here?