May-24-2022, 10:06 AM
(This post was last modified: May-27-2022, 04:30 AM by Rajasekaran.)
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:
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()
Larz60+ write May-24-2022, 03:47 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
fixed error message, Please add code between BBCode python tags.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
fixed error message, Please add code between BBCode python tags.
Attached Files
OCR.py (Size: 765 bytes / Downloads: 120)