-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (39 loc) · 1.29 KB
/
main.py
File metadata and controls
48 lines (39 loc) · 1.29 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
import sys
import os
import subprocess
def main():
"""
MLquick 启动入口
启动 Streamlit 应用程序
"""
# 获取当前脚本所在目录
current_dir = os.path.dirname(os.path.abspath(__file__))
# 构建 MLquick.py 的完整路径
mlquick_path = os.path.join(current_dir, "src", "MLquick.py")
# 检查文件是否存在
if not os.path.exists(mlquick_path):
print(f"错误: 找不到文件 {mlquick_path}")
return 1
print("正在启动 MLquick 机器学习平台...")
print(f"应用路径: {mlquick_path}")
print("请等待浏览器自动打开...")
try:
# 使用 subprocess 启动 streamlit
# 直接运行 streamlit run 命令
subprocess.run([
sys.executable, "-m", "streamlit", "run", mlquick_path
], check=True)
except subprocess.CalledProcessError as e:
print(f"启动失败: {e}")
return 1
except FileNotFoundError:
print("错误: 未找到 streamlit,请确保已安装 streamlit")
print("安装命令: pip install streamlit")
return 1
except KeyboardInterrupt:
print("\n应用已停止")
return 0
return 0
if __name__ == "__main__":
exit_code = main()
sys.exit(exit_code)