-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
131 lines (114 loc) · 4.26 KB
/
install.py
File metadata and controls
131 lines (114 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env python3
"""
Installation script for Student Performance Tracker
Handles Python 3.13 compatibility issues
"""
import subprocess
import sys
import os
def run_command(command):
"""Run a command and return success status"""
try:
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
return True, result.stdout
except subprocess.CalledProcessError as e:
return False, e.stderr
def main():
print("🎓 Student Performance Tracker - Installation Script")
print("=" * 60)
print(f"Python version: {sys.version}")
# Check Python version
if sys.version_info < (3, 8):
print("❌ Error: Python 3.8 or higher is required")
sys.exit(1)
# For Python 3.13, we need to handle some dependencies carefully
if sys.version_info >= (3, 13):
print("⚠️ Python 3.13 detected - using compatible package versions")
# Install packages one by one to handle conflicts
packages = [
"streamlit==1.37.0",
"pandas==2.2.2",
"altair==5.3.0",
"plotly==5.22.0",
"fpdf2==2.7.9"
]
# Optional packages that might have issues
optional_packages = [
"mysql-connector-python==9.0.0",
"reportlab==4.2.2",
"streamlit-extras==0.4.3",
"Pillow==10.4.0",
"openpyxl==3.1.5",
"matplotlib==3.9.1"
]
print("\n📦 Installing core packages...")
for package in packages:
print(f"Installing {package}...")
success, output = run_command(f"pip install {package}")
if success:
print(f"✅ {package} installed successfully")
else:
print(f"❌ Failed to install {package}: {output}")
print("\n📦 Installing optional packages...")
for package in optional_packages:
print(f"Installing {package}...")
success, output = run_command(f"pip install {package}")
if success:
print(f"✅ {package} installed successfully")
else:
print(f"⚠️ {package} failed (optional): {output}")
else:
# For older Python versions, try regular requirements
print("📦 Installing all requirements...")
success, output = run_command("pip install -r requirements.txt")
if success:
print("✅ All requirements installed successfully")
else:
print(f"❌ Installation failed: {output}")
print("\nTrying minimal requirements...")
success2, output2 = run_command("pip install -r requirements-minimal.txt")
if success2:
print("✅ Minimal requirements installed")
else:
print(f"❌ Minimal installation also failed: {output2}")
sys.exit(1)
print("\n🧪 Testing installation...")
# Test imports
test_imports = [
("streamlit", "Streamlit web framework"),
("pandas", "Data processing"),
("altair", "Charts and visualization"),
("plotly", "Interactive charts")
]
failed_imports = []
for module, description in test_imports:
try:
__import__(module)
print(f"✅ {description} - OK")
except ImportError:
print(f"❌ {description} - FAILED")
failed_imports.append(module)
# Test optional imports
optional_imports = [
("mysql.connector", "MySQL database support"),
("fpdf", "PDF generation"),
("matplotlib", "Additional charts")
]
for module, description in optional_imports:
try:
__import__(module)
print(f"✅ {description} - OK")
except ImportError:
print(f"⚠️ {description} - Not available (optional)")
if failed_imports:
print(f"\n❌ Critical modules failed to install: {', '.join(failed_imports)}")
print("The application may not work properly.")
sys.exit(1)
else:
print("\n🎉 Installation completed successfully!")
print("\nYou can now run the application with:")
print("python start.py")
print("or")
print("streamlit run app.py")
if __name__ == "__main__":
main()