gpt4 book ai didi

python - 找不到文件错误 : Could not find module 'C:\Users\PycharmProjects\(path...)\site-packages\pyzbar\libzbar-64.dll' (or one of its dependencies

转载 作者:行者123 更新时间:2023-12-05 05:57:38 25 4
gpt4 key购买 nike

我收到 FileNotFoundError: Could not find module 'C:\Users\new user.LAPTOP-5GLT5PL6\PycharmProjects\pythonProject\venv\lib\site-packages\pyzbar\libzbar-64.dll'(或它的依赖项之一)。尝试使用带有构造函数语法的完整路径。 但是,正如您在 screenshot 中看到的那样这里 libzbar-64.dll 存储在上面指定的位置。代码如下,应该是使用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()

最佳答案

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

我做了并且工作了!

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

关于python - 找不到文件错误 : Could not find module 'C:\Users\PycharmProjects\(path...)\site-packages\pyzbar\libzbar-64.dll' (or one of its dependencies,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68768606/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com