0

I write a python script to read the pdfs files in the current folder(inside shared disk) looking for specific number and then search in other folder (same shared disk) that number. If match, with PyMuPDF I merge both files in a new file. After that, move that file to other folder. The thing is that I need to do it in my work's notebook, inside a shared disk. (no python installed in that disk). I have Anaconda installed only in my c:\user of my notebook. So, with jupyter notebook the script runs perfect, but when I convert it to exe file (with pyinstaller), it does not work anymore, nor in my C disk neither the shared disk. I need an exe file to execute that script inside the shared disk.

My script below


import fitz
import os
import shutil
from tkinter import *
from tkinter import messagebox

archis = os.listdir()
archivos = os.listdir("N:\\...\\DJVE 2021")

window = Tk()
window.eval('tk::PlaceWindow %s center' % window.winfo_toplevel())
window.withdraw()

dejotas = 0
cant_veps = 0

unir_djs = messagebox.askquestion("Pregunta","Desea unir los Veps a las DJVE?")
if unir_djs == "yes":
 
    try:
        
        for files in archis:
            files_splited = files.split(".")
            if files_splited[1] == "pdf":
                raw_file = fitz.open(files)

                for pageNumber, page in enumerate(raw_file.pages(), start = 1):
                    text = page.getText()

                    try:
                        for files_dj in archivos:
                            if files_dj[0:15] in text:
                                file_dj = fitz.open("N:\\....\\DJVE 2021\\" + files_dj)
                                raw_file.insertPDF(file_dj, start_at=0)
                                raw_file.save(files_dj)
                                file_dj.close()
                                raw_file.close()
                                shutil.move(files_dj, "N:\\...\\DJVE 2021\\Djve con veps")
                                dejotas += 1
                                cant_veps += 1 
                    except:
                        messagebox.showerror("Error","Problema con el archivo de djve.")
                        
        
            
            
    except:
        messagebox.showerror("Error","Problema con el archivo de veps.")


            
else:
    messagebox.showinfo("Informacion","No se ejecuto ninguna tarea.")
    


if unir_djs == "yes":

    messagebox.showinfo("Informacion",f"Numero de DJVE procesadas {dejotas}")
    messagebox.showinfo("Informacion",f"Favor borrar los {len(lista_veps)} veps de esta carpeta.\nGracias. ")

window.deiconify()
window.destroy()
window.quit()

Thanks!

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
  • What does it not do? – Tim Roberts Apr 29 '21 at 22:56
  • @TimRoberts never opens. – Facundo Arroyo Apr 29 '21 at 23:00
  • Wrapping a Python program in an executable is more complex than you may imagine, and sometimes it can't be done without input from you. You don't mention having set up a `.spec` file and you may need to do that. `pyinstaller`'s documentation has a very helpful section called When things go wrong. I suggest you work through that. – BoarGules Apr 29 '21 at 23:50

0 Answers0