-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathui.py
More file actions
36 lines (26 loc) · 784 Bytes
/
Copy pathui.py
File metadata and controls
36 lines (26 loc) · 784 Bytes
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
import sys
import os
import subprocess
from QtFusion.path import abs_path
def run_script(script_path):
"""
使用当前 Python 环境运行指定的脚本。
Args:
script_path (str): 要运行的脚本路径
Returns:
None
"""
# 获取当前 Python 解释器的路径
python_path = sys.executable
# 构建运行命令
command = f'"{python_path}" -m streamlit run "{script_path}"'
# 执行命令
result = subprocess.run(command, shell=True)
if result.returncode != 0:
print("脚本运行出错。")
# 实例化并运行应用
if __name__ == "__main__":
# 指定您的脚本路径
script_path = abs_path("web.py")
# 运行脚本
run_script(script_path)