dev2607 commited on
Commit
bb07fca
·
verified ·
1 Parent(s): 6308eb0

Create app_launcher.py

Browse files
Files changed (1) hide show
  1. app_launcher.py +42 -0
app_launcher.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ import subprocess
4
+
5
+ # Force installation of Tesseract at runtime
6
+ def install_tesseract():
7
+ print("Installing Tesseract OCR...")
8
+ try:
9
+ # Update repositories
10
+ subprocess.run(['apt-get', 'update'], check=True)
11
+ # Install Tesseract and dependencies
12
+ subprocess.run(['apt-get', 'install', '-y', 'tesseract-ocr', 'libtesseract-dev',
13
+ 'tesseract-ocr-eng', 'poppler-utils'], check=True)
14
+ print("Tesseract OCR installation complete.")
15
+ return True
16
+ except Exception as e:
17
+ print(f"Error installing Tesseract: {str(e)}")
18
+ return False
19
+
20
+ # Check if Tesseract is installed
21
+ def is_tesseract_installed():
22
+ try:
23
+ result = subprocess.run(['tesseract', '--version'],
24
+ capture_output=True, text=True, check=True)
25
+ print(f"Tesseract is installed: {result.stdout.strip()}")
26
+ return True
27
+ except Exception:
28
+ return False
29
+
30
+ # Main entry point
31
+ if __name__ == "__main__":
32
+ # Check if Tesseract is installed
33
+ if not is_tesseract_installed():
34
+ # Try to install it
35
+ if install_tesseract():
36
+ print("Tesseract installed successfully.")
37
+ else:
38
+ print("Failed to install Tesseract. Continuing anyway...")
39
+
40
+ # Run the main app
41
+ import app
42
+ app.app.launch()