初次提交
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
def check_requirements():
|
||||
print("===================================================")
|
||||
print(" BYWVoiceHub 点歌系统模拟器启动程序")
|
||||
print("===================================================")
|
||||
print("[1/2] 正在检查依赖包...")
|
||||
|
||||
try:
|
||||
import requests
|
||||
print("[成功] 依赖包检查完毕。")
|
||||
except ImportError:
|
||||
print("[警告] 未找到 requests,正在尝试安装...")
|
||||
try:
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", "requests", "-q"])
|
||||
print("[成功] 依赖包安装完毕。")
|
||||
except Exception as e:
|
||||
print(f"[错误] 安装依赖失败: {e}")
|
||||
print("请尝试手动运行: pip install requests")
|
||||
input("按回车键退出...")
|
||||
sys.exit(1)
|
||||
|
||||
print("[2/2] 正在启动模拟器 GUI...")
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
simulator_path = os.path.join(script_dir, "simulator.py")
|
||||
|
||||
if sys.platform == "win32":
|
||||
# 在 Windows 上使用 pythonw 启动以隐藏控制台
|
||||
pythonw_exe = sys.executable.replace("python.exe", "pythonw.exe")
|
||||
if not os.path.exists(pythonw_exe):
|
||||
pythonw_exe = sys.executable
|
||||
subprocess.Popen([pythonw_exe, simulator_path])
|
||||
else:
|
||||
subprocess.Popen([sys.executable, simulator_path])
|
||||
|
||||
print("启动成功!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
check_requirements()
|
||||
Reference in New Issue
Block a user