Python Forum
Converted EXE file size is too large
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converted EXE file size is too large
#1
I have converted the python script to exe format using the below command, but the exe file size is too large. So when executing the exe file, it is taking a long time to start the execution. Could you please help us to solve this issue. Thanks in Advance.

pyinstaller.exe --onefile tiff-2-txt.py

Script File Size: 1.90 KB
Converted EXE file size: 153 MB

Python = 3.8
Pyinstaller Version = 5.8.0

import os.path
import cv2
import pytesseract



'''
- language will be defined in "lang.ini" file in the same path of input files.
- language code should be three digit iso code, multiple language should be add by separation of "+" symbol. e.g.: eng+hin
- Tesseract version 5 should be installed in "C:\Program Files\Tesseract-OCR"
'''
print("\n *********************************\n")
print("\n OCR Tool - Output: Text format\n")
print("\n Language code: Three letter iso code\n")
print("\n Multiple language: add by separation of ""+"" symbol. e.g.: eng+hin \n")
print("\n *********************************\n\n")

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

filepath = filepath1 + "\\"

filelist = os.path.isdir(filepath)


for fname in os.listdir(filepath):
    if not fname.endswith(".tif"):
        continue
    path = os.path.join(filepath, fname) 
    print(path)
    pytesseract.pytesseract.tesseract_cmd=r'C:\Program Files\Tesseract-OCR\tesseract.exe'
    img = cv2.imread(path)  # load the image from the path using OpenCV library
    langu = filepath + "lang.ini"
    with open(langu) as f:   # open the ini file
        ini = f.read()       # read the ini file
    text = pytesseract.image_to_string(img, ini)    
    test = os.path.splitext(fname)[0]
    txtname = filepath + test + ".txt"
    f = open(txtname,"w+", encoding="utf-8")  
    f.write(text)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


print("OCR Completed")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  validate large json file with millions of records in batches herobpv 3 1,282 Dec-10-2022, 10:36 PM
Last Post: bowlofred
  Python converted EXE not working Rajasekaran 1 1,591 Aug-22-2022, 05:56 PM
Last Post: hismail_sa
  check if a file exist on the internet and get the size kucingkembar 6 1,800 Apr-16-2022, 05:09 PM
Last Post: kucingkembar
  Pyinstaller distribution file seems too large hammer 4 2,744 Mar-31-2022, 02:33 PM
Last Post: snippsat
  Initializing, reading and updating a large JSON file medatib531 0 1,798 Mar-10-2022, 07:58 PM
Last Post: medatib531
  Converted Pipe Delimited text file to CSV file atomxkai 4 7,018 Feb-11-2022, 12:38 AM
Last Post: atomxkai
  Issue when using open() in converted exe skakalpes 2 1,577 Feb-02-2022, 02:42 PM
Last Post: snippsat
  numpy.dot() result different with classic computation for large-size arrays geekgeek 5 1,902 Jan-25-2022, 09:45 PM
Last Post: Gribouillis
  can't read QRcode in large file simoneek 0 1,516 Sep-16-2020, 08:52 AM
Last Post: simoneek
  Runs perfect in Python but fails to print last statement when converted to .exe. Help sunil422 3 2,838 Aug-13-2020, 01:22 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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