1 year ago

#354436

test-img

Jammmme

Exe-file is not working as expected after converting a python-script with pyinstaller

I am trying to use python to automate the conversion of pdf-docs into png-docs (pdf2image). So far the python-script works as hoped, but when I try to distribute my little programm to other people (using pyinstaller to convert the script into a exe-file) something goes wrong. However, when I run my python-script the task is executed properly, but after starting the exe literally nothing happens.

Unfortunalety I have few experience in coding and my code might be laborious but I will be very thankful, if someone can help me.

from pdf2image import convert_from_path
import os
from pathlib import Path


absolutePath = os.path.dirname(os.path.abspath(__file__)) 
newlist = [] 
counter = 1


def collectPDF(): 
    items = os.listdir(absolutePath)
    for names in items:
        if names.endswith('.pdf'):
            newlist.append(names) 
        number = list(range(100))
        for numb in number:
            if names.endswith(str(numb) + '.png'):
                exit()


def convert(filename):
    pages = convert_from_path(absolutePath + '/' + filename, 300)
    for page in pages:
        global counter
        page.save(absolutePath + '/' + str(counter) + '.png', 'PNG')
        counter += 1

collectPDF()
for name in newlist:
    convert(name)
del newlist[:] 

python

pyinstaller

exe

pdf2image

0 Answers

Your Answer

Accepted video resources