0

I tried to write a simple program for converting PDF files to JPG. The main idea is a simple .exe file that will find all PDF files in the same directory, and after converting them to JPG put them in the new folder. And I did it! Using pdf2image, my program doing exactly as I want and as .py and as .exe. But, after running this program on another PC I got an error with popper >following Cmd screenshot image of cmd prompt showing error: "Unable to get page count. Is Poppler installed and in PATH?" So, I understand, the program tries to find a popper. And sure on another PC program can't find it.

I tried --hidden-import, and --onedir, --onefile e.t.c. Also saw some similar problem here, as:

PyInstaller and Poppler

Include poppler while generating an application using pyinstaller

But, or I do something wrong, or can't clearly understand how to do solutions in this questions.

What should I do?

#P.S. Maybe, there is a better library or module to create this kind of program?

Whole code:

import os
import pdf2image
from pdf2image import convert_from_path
from inspect import getsourcefile
from pdf2image.exceptions import (
                                    PDFInfoNotInstalledError,
                                    PDFPageCountError,
                                    PDFSyntaxError
)

#  Create output direction
#  Direction of executable file
script_dir = os.path.abspath(getsourcefile(lambda:0))
#  print(script_dir)
output_dir = 'JPG'

#  List for files which wasn't converted
error_list = []

#  If path don't exist - create
if not os.path.exists(output_dir):
    os.makedirs(output_dir)
    #print('Path has been created', "\n")
else:
    pass
    #print('Directory exist', "\n")

#  Show all files in directory
file_list = os.listdir()
print(file_list, "List of files")

for file in file_list:
    
    try:
        # print(file)
        pages = convert_from_path(file, dpi=300, fmt='jpg', output_folder=output_dir, output_file=file)
    
    except Exception as e: print(e)


print("File wasn't converted:", "\n")
if len(error_list) == 0:
    print(0, "\n")
else:
    for f in error_list:
        print(f)

input("Done! Press Enter")

Multihunter
  • 5,520
  • 2
  • 25
  • 38
  • Please copy-paste terminal output instead of screenshotting, and give a Minimum Reproduceable Example. – Seth Feb 02 '21 at 16:13
  • Does this answer your question? [PyInstaller and Poppler](https://stackoverflow.com/questions/12909887/pyinstaller-and-poppler) – Seth Feb 02 '21 at 16:13

0 Answers0