Python Forum
Python converted EXE not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python converted EXE not working
#2
(May-24-2022, 10:06 AM)Rajasekaran Wrote: I have created a tool for OCR the content from the TIFF images and its working fine when executing from the source code.
However when executing the same from converted EXE it displayed the error message as below. Please help us to resolve this issue. Thanks in Advance...

Error Message from EXE:

Error:
Traceback (most recent call last): File "OCR.py", line 4, in <module> File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module File "ocrmypdf\__init__.py", line 13, in <module> File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module File "ocrmypdf\_version.py", line 16, in <module> File "importlib_metadata\__init__.py", line 1002, in version File "importlib_metadata\__init__.py", line 975, in distribution File "importlib_metadata\__init__.py", line 566, in from_name importlib_metadata.PackageNotFoundError: No package metadata was found for ocrmy pdf [4156] Failed to execute script 'OCR' due to unhandled exception![/color] [b]EXE Creator Command:[/b] pyinstaller --onefile OCR.py [b]System Details:[/b] Windows 7 64-bit [b]Version:[/b] Python 3.8 [b]ocrmypdf.exe version:[/b] 13.4.4
OCR Python Code:
import sys
import os
from PIL import Image
import ocrmypdf


filepath1 = input(" Enter the File path: ")

filepath = filepath1 + "\\"

filelist = os.path.isdir(filepath)

langu = filepath + "lang.ini"

for fname in os.listdir(filepath):
    print(fname)
    if not fname.endswith(".tif"):
        continue
    input_file = os.path.join(filepath, fname) 
    im1 = Image.open(input_file).convert("RGB")
    pname = os.path.splitext(fname)[0]
    output_file = filepath + pname + ".pdf"
    f1 = open(output_file, "w+b")
    with open(langu) as f:   # open the ini file
        ini = f.read()       # read the ini file
    ocrmypdf.ocr(input_file, output_file, language=ini, force_ocr=True, output="pdf", jpeg_quality="100")
    f1.close()

Good day,

Have you managed to fix this problem. I am having the same issue.

Regards,
Hussein Ismail
Reply


Messages In This Thread
Python converted EXE not working - by Rajasekaran - May-24-2022, 10:06 AM
RE: Python converted EXE not working - by hismail_sa - Aug-22-2022, 05:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Converted EXE file size is too large Rajasekaran 0 1,540 Mar-30-2023, 11:50 AM
Last Post: Rajasekaran
  Issue when using open() in converted exe skakalpes 2 1,595 Feb-02-2022, 02:42 PM
Last Post: snippsat
  Runs perfect in Python but fails to print last statement when converted to .exe. Help sunil422 3 2,852 Aug-13-2020, 01:22 PM
Last Post: deanhystad
  Failed to insert record into MySQL table.Python type tuple cannot be converted farah97 3 21,672 Dec-26-2019, 02:01 PM
Last Post: buran
  TypeError: not all arguments converted during string formatting RedSkeleton007 1 14,993 Jul-15-2018, 08:51 PM
Last Post: ichabod801
  isocalendar value converted back to start of week. cspower 1 2,558 May-30-2018, 05:13 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020