3

I am getting FileNotFoundError: Could not find module 'C:\Users(path...)\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()
Akash Sharma
  • 134
  • 1
  • 3
  • 13

4 Answers4

1

Same error. Reading on Pypi page, they say that in case of ImportError on Windows we should install "Visual C++ Redistributable Package per Visual Studio 2013"

I did and worked!

https://pypi.org/project/pyzbar/ , see "Windows Import Error".

barbax7
  • 148
  • 5
  • i got the latest build of visual c++ redistributable, does it change the thing or is about a specific version.......p.s. i still cant use pyzbar – Akash Sharma Sep 29 '21 at 06:02
  • as i said, i installed that specific version, as explained on pypi, and worked. I don't know if it would work with other versions. – barbax7 Sep 29 '21 at 14:13
0

Are you trying to import libzbar or pyzbar? if you're trying to import pyzbar it doesnt seem that pyzbar is in the site packages

Try to install pip install pyzbar first

MakeTheErrorDie
  • 87
  • 1
  • 1
  • 10
0

I ran into the same problem and tried to change python and PyCharm versions, but it still didn't work. Now I use python3.9.7 and PyCharm2020.2.5.

My error tip is "FileNotFoundError: Could not find module 'D:\python3.9.7\Lib\site-packages\PySmartCard\ReaderLib_64.dll' (or one of its dependencies). Try using the full path with constructor syntax."

Strangely, I have this .dll file in my file path.

Lon9
  • 11
  • 1
    This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/29857154) – Gino Mempin Sep 18 '21 at 09:47
  • Did you solve the problem? – Calvin_Z Jul 05 '23 at 07:59
0

should install "Visual C++ Redistributable Package per Visual Studio 2013"

https://www.microsoft.com/en-US/download/details.aspx?id=40784

cnyb
  • 1
  • 1
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/33357956) – LSeu Dec 12 '22 at 16:14