61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
PyQt6安装脚本
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
|
|
def install_package(package):
|
|
"""安装Python包"""
|
|
try:
|
|
print(f"正在安装 {package}...")
|
|
result = subprocess.run(
|
|
[sys.executable, "-m", "pip", "install", package],
|
|
capture_output=True,
|
|
text=True
|
|
)
|
|
|
|
if result.returncode == 0:
|
|
print(f"✓ {package} 安装成功")
|
|
return True
|
|
else:
|
|
print(f"✗ {package} 安装失败:")
|
|
print(result.stderr)
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"✗ 安装 {package} 时出错: {e}")
|
|
return False
|
|
|
|
def main():
|
|
print("=== PyQt6 安装器 ===\n")
|
|
|
|
packages = [
|
|
"PyQt6>=6.4.0",
|
|
"numpy>=1.21.0"
|
|
]
|
|
|
|
success_count = 0
|
|
|
|
for package in packages:
|
|
if install_package(package):
|
|
success_count += 1
|
|
print()
|
|
|
|
print(f"=== 安装结果: {success_count}/{len(packages)} 成功 ===")
|
|
|
|
if success_count == len(packages):
|
|
print("\n✅ 所有包安装成功!")
|
|
print("\n现在可以运行测试:")
|
|
print("python3 test_pyqt6.py")
|
|
print("\n启动GUI界面:")
|
|
print("python3 monitor_gui.py")
|
|
return True
|
|
else:
|
|
print("\n❌ 部分包安装失败,请检查网络和权限")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
success = main()
|
|
sys.exit(0 if success else 1) |