0

I have problem with convert using pdf2image module. I don't know where is something wrong with the code. When I run program and paste path the error shows.

Code below:

import os
from pdf2image import convert_from_path
from tkinter import *
from tkinter import messagebox

 
 
def convert():
    try:
        for img in images:
            for idx, img in enumerate(images, start=1):
                img.save(os.path.join(os.cudir,'new_folder',f"image_{idx}.jpg"))


    except:
        Result = "FileNotFoundError"
        messagebox.showinfo("Result", Result)

    else:
        Result = "success"
        messagebox.showinfo("Result", Result)
 
 
 
master = Tk()
Label(master, text="File Location").grid(row=0, sticky=W)
 
e1 = Entry(master)
e1.grid(row=0, column=1)
 
b = Button(master, text="Convert", command=convert)
b.grid(row=0, column=2,columnspan=2, rowspan=2,padx=5, pady=5)
  
mainloop()

enter image description here

  • You should save the error that is being caught, and print it out. It likely has information that will tell you what the problem is. – Bryan Oakley Sep 04 '22 at 23:02

1 Answers1

0

It's just a guess, but does the folder os.path.join(os.cudir,'new_folder') already exist? This code seems to assume it does.

Try printing more information about the error:

    except Exception as e:
        Result = f"FileNotFoundError: {e}"
        messagebox.showinfo("Result", Result)
DraftyHat
  • 428
  • 1
  • 2
  • 6