I'm currently building an app that uses OCR to extract data from PDF files using PYQT5, and I need to use the terminal to convert the pdf into jpeg's before running the OCR; however, when I run this subprocess after compiling it crashes, but it works perfectly if I don't compile the program.
It seems to me that the problem lies within the subprocess call. I've tried many different ways, but I don't know why my app keeps crashing after I compile and run the conversion.
NOTE: For PDF to JPEG I'm using ImageMagick
Currently using to compile:
py2applet --make-setup main.py
python3 setup.py py2app
Converter.py:
from subprocess import call
from PIL import Image
import pytesseract
from PyQt5 import QtWidgets
from ocrgui import Ui_MainWindow
class ImageConverter(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.show()
self.sbmt_btn_convert.clicked.connect(self.convert_image)
def convert_image(self): #Converts image into jpeg
text = str(self.input_convert.text())
output = str(self.output_convert.text())
convert = 'converted.jpeg'
call('convert -density 300 ' + text + ' ' + convert, shell=True)
im = Image.open(convert)
text = pytesseract.image_to_string(im, lang = 'eng')
file = open(output,'w')
file.write(text)
file.close()
call('rm converted.jpeg', shell=True)
print('Succesfully created')
Main.py:
import sys
from PyQt5.QtWidgets import QApplication
from calculator import CalculatorWindow
app = QApplication(sys.argv)
calculator = CalculatorWindow()
sys.exit(app.exec())
I think that problem in the next module:
pathPython\Lib\site-packages\PIL\ImageQt.py
Try to put # on the next lines: