1

I am getting FileNotFoundError: Could not find module 'C:\Users\new user.LAPTOP-5GLT5PL6\PycharmProjects\pythonProject\venv\lib\site-packages\pyzbar\libzbar-64.dll' (or one of its dependencies). Try using the full path with constructor syntax. But, as you can see in the screenshot here that libzbar-64.dll is stored in the above specified location. code is below , its supposed to be a qr code application using tkinter

from tkinter import *
from tkinter import ttk
from tkinter import filedialog

from PIL import Image, ImageTk
from pyzbar.pyzbar import decode
import pyqrcode
import os

root = Tk()
root.title("QR code application")
note = ttk.Notebook(root)
note.pack()
# create frames to add on tabs
frame1 = Frame(note, height=400, width=150, bg='white')
frame1.pack(fill="both", expand=True)
frame2 = Frame(note, height=400, width=150, bg='white')
frame2.pack(fill="both", expand=True)
s = ttk.Style()
s.theme_create("style", parent="alt", settings={
    "TNotebook.Tab": {"configure": {"padding": [20, 10],
                                    "font": ('Times', '20', 'bold')}}})
s.theme_use("style")
# add tabs
note.add(frame1, text="Generate QR Code")
note.add(frame2, text="Read QR Code")
# create canvas to display image
canvas1 = Canvas(frame1, width="400", height="300", relief=RIDGE, bd=2)
canvas1.pack(padx=10, pady=10)
canvas2 = Canvas(frame2, width="400", height="400", relief=RIDGE, bd=2)
canvas2.pack(padx=10, pady=10)


def generate():
    if data_entry.get() != '' and save_entry.get() != '':
        qr = pyqrcode.create(data_entry.get())
        img = qr.png(save_entry.get() + ".png", scale=5)
        info = Label(frame1, text="Generated QR code:", font=('ariel 15 bold'))
        info.place(x=60, y=40)
        img = Image.open(save_entry.get() + ".png")
        img = ImageTk.PhotoImage(img)
        canvas1.create_image(200, 180, image=img)
        canvas1.image = img
    else:
        info = Label(frame1, text="Please enter the data for QR code", font=('ariel 15 bold'))
        info.place(x=80, y=140)


def selected():
    img_path = filedialog.askopenfilename(initialdir=os.getcwd(),
                                          title="Select Image", filetype=(
            ("PNG file", "*.png"), ("All files", "*.*")))
    img = Image.open(img_path)
    img = ImageTk.PhotoImage(img)
    canvas2.create_image(200, 190, image=img)
    canvas2.image = img
    d = decode(Image.open(img_path))
    data = d[0].data.decode()
    qrcode_data = Label(frame2, text=data, bg='gold', fg='black', font=('ariel 15 bold'), relief=GROOVE)
    qrcode_data.place(x=150, y=380)


data_label = Label(frame1, text='Enter data:', font=('ariel 15 bold'), bg='white')
data_label.place(x=61, y=330)
save_label = Label(frame1, text='Enter name \n to save with:', font=('ariel 15 bold'), bg='white')
save_label.place(x=55, y=360)
data_entry = Entry(frame1, font=('ariel 15 bold'), relief=GROOVE, bd=3)
data_entry.place(x=197, y=330)
save_entry = Entry(frame1, font=('ariel 15 bold'), relief=GROOVE, bd=3)
save_entry.place(x=197, y=380)
btn1 = Button(frame1, text="Generate", bg='black', fg='gold', font=('ariel 15 bold'), relief=GROOVE, command=generate)
btn1.place(x=85, y=425)
btn2 = Button(frame1, text="Exit", width=10, bg='black', fg='gold', font=('ariel 15 bold'), relief=GROOVE,
              command=root.destroy)
btn2.place(x=255, y=425)
btn2 = Button(frame2, text="Select Image", bg='black', fg='gold', font=('ariel 15 bold'), relief=GROOVE,
              command=selected)
btn2.pack(side=LEFT, padx=50, pady=5)
btn3 = Button(frame2, text="Exit", width=12, bg='black', fg='gold', font=('ariel 15 bold'), relief=GROOVE,
              command=root.destroy)
btn3.pack(side=LEFT, padx=10, pady=5)
root.mainloop()
4

3 回答 3

0

同样的错误。在 Pypi 页面上阅读,他们说如果 Windows 上出现 ImportError,我们应该安装“Visual C++ Redistributable Package per Visual Studio 2013”

我做了并且工作了!

https://pypi.org/project/pyzbar/,请参阅“Windows 导入错误”。

于 2021-09-28T17:00:43.323 回答
0

我遇到了同样的问题并试图更改 python 和 PyCharm 版本,但它仍然没有工作。现在我使用 python3.9.7 和 PyCharm2020.2.5。

我的错误提示是“FileNotFoundError:找不到模块 'D:\python3.9.7\Lib\site-packages\PySmartCard\ReaderLib_64.dll'(或其依赖项之一)。尝试使用带有构造函数语法的完整路径。”

奇怪的是,我的文件路径中有这个 .dll 文件。

于 2021-09-18T06:37:53.643 回答
0

您是要导入 libzbar 还是 pyzbar?如果您尝试导入pyzbar它似乎不在pyzbar站点包中

尝试先安装 pip pyzbarinstall

于 2021-08-13T08:01:38.850 回答