You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Curriculum_Design/emergency_fix.sh

55 lines
1.8 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
# PyQt5 紧急修复脚本 - 终极解决方案
echo "🚨 PyQt5 紧急修复中..."
# 1. 完全清理现有安装
echo "📦 步骤1: 清理PyQt5安装..."
pip uninstall PyQt5 PyQt5-Qt5 PyQt5-sip -y
rm -rf /Users/maziang/Documents/CodingWorkPlace/Code/Curriculum_Design/.venv/lib/python3.9/site-packages/PyQt5*
# 2. 重新安装PyQt5
echo "📦 步骤2: 重新安装PyQt5..."
pip install PyQt5==5.15.10 --force-reinstall --no-cache-dir
# 3. 设置环境变量
echo "🔧 步骤3: 设置环境变量..."
export QT_PLUGIN_PATH="/Users/maziang/Documents/CodingWorkPlace/Code/Curriculum_Design/.venv/lib/python3.9/site-packages/PyQt5/Qt5/plugins"
export QT_QPA_PLATFORM_PLUGIN_PATH="/Users/maziang/Documents/CodingWorkPlace/Code/Curriculum_Design/.venv/lib/python3.9/site-packages/PyQt5/Qt5/plugins/platforms"
export QT_QPA_PLATFORM="cocoa"
export QT_MAC_WANTS_LAYER="1"
export QT_LOGGING_RULES="qt.qpa.*=false"
# 4. 验证安装
echo "✅ 步骤4: 验证安装..."
python -c "
import sys
import os
os.environ['QT_PLUGIN_PATH'] = '$QT_PLUGIN_PATH'
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = '$QT_QPA_PLATFORM_PLUGIN_PATH'
os.environ['QT_QPA_PLATFORM'] = 'cocoa'
os.environ['QT_MAC_WANTS_LAYER'] = '1'
try:
from PyQt5.QtWidgets import QApplication, QLabel
from PyQt5.QtCore import Qt
app = QApplication(sys.argv)
label = QLabel('PyQt5修复成功✅')
label.setAlignment(Qt.AlignCenter)
label.resize(200, 100)
label.show()
from PyQt5.QtCore import QTimer
QTimer.singleShot(1500, app.quit)
app.exec_()
print('✅ PyQt5验证成功')
except Exception as e:
print(f'❌ PyQt5验证失败: {e}')
import traceback
traceback.print_exc()
"
echo "🎉 修复完成!"
echo "现在可以运行: python src/main.py"