MetaCore-startup/Doc/安装PyQt5指南.md
2025-10-11 09:24:06 +08:00

191 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PyQt5安装指南
## 🔧 Windows系统安装PyQt5
### 方法1使用pip安装推荐
#### 1. 检查Python是否已安装
```cmd
python --version
```
如果显示版本号说明Python已安装。如果提示命令不存在需要先安装Python。
#### 2. 安装Python如果未安装
1. 访问 https://www.python.org/downloads/
2. 下载最新版本的Python
3. 安装时勾选"Add Python to PATH"
#### 3. 安装PyQt5
```cmd
pip install PyQt5
```
#### 4. 验证安装
```cmd
python -c "import PyQt5; print('PyQt5安装成功')"
```
### 方法2使用conda安装
#### 1. 安装Anaconda或Miniconda
- 下载地址https://www.anaconda.com/products/distribution
#### 2. 安装PyQt5
```cmd
conda install pyqt
```
### 方法3离线安装
#### 1. 下载PyQt5安装包
访问 https://pypi.org/project/PyQt5/#files 下载对应的.whl文件
#### 2. 离线安装
```cmd
pip install PyQt5-5.15.7-cp39-cp39-win_amd64.whl
```
## 🚀 运行MetaCore应用
### 1. 确认PyQt5已安装
```cmd
python -c "from PyQt5.QtWidgets import QApplication; print('PyQt5可用')"
```
### 2. 运行应用
```cmd
cd MetaCore目录
python main.py
```
### 3. 如果遇到错误
#### 错误1ModuleNotFoundError: No module named 'PyQt5'
**解决方案:**
```cmd
pip install PyQt5
```
#### 错误2ImportError: DLL load failed
**解决方案:**
```cmd
pip uninstall PyQt5
pip install PyQt5
```
#### 错误3Python命令不存在
**解决方案:**
1. 重新安装Python并勾选"Add to PATH"
2. 或者使用完整路径:
```cmd
C:\Python39\python.exe main.py
```
## 📋 系统要求
### 最低要求
- Windows 7 SP1 或更高版本
- Python 3.6 或更高版本
- 2GB RAM
- 100MB 可用磁盘空间
### 推荐配置
- Windows 10 或更高版本
- Python 3.8 或更高版本
- 4GB RAM
- SSD硬盘
## 🔍 故障排除
### 1. 检查Python版本
```cmd
python --version
```
确保版本为3.6或更高。
### 2. 检查pip版本
```cmd
pip --version
```
如果pip不可用可以重新安装Python。
### 3. 更新pip
```cmd
python -m pip install --upgrade pip
```
### 4. 清理缓存
```cmd
pip cache purge
```
### 5. 使用国内镜像源(如果下载慢)
```cmd
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple PyQt5
```
## 🎯 验证安装成功
### 运行测试脚本
创建一个测试文件 `test_pyqt5.py`
```python
import sys
from PyQt5.QtWidgets import QApplication, QLabel, QWidget
def test_pyqt5():
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle('PyQt5测试')
window.setGeometry(100, 100, 300, 200)
label = QLabel('PyQt5安装成功', window)
label.move(100, 80)
window.show()
print("PyQt5测试窗口已显示关闭窗口退出测试")
sys.exit(app.exec_())
if __name__ == '__main__':
test_pyqt5()
```
运行测试:
```cmd
python test_pyqt5.py
```
如果出现一个窗口显示"PyQt5安装成功",说明安装正确。
## 📞 获取帮助
如果仍然遇到问题:
1. **检查Python环境**
```cmd
where python
python -m site
```
2. **重新安装Python**
- 卸载现有Python
- 重新下载安装,确保勾选"Add to PATH"
3. **使用虚拟环境**
```cmd
python -m venv metacore_env
metacore_env\Scripts\activate
pip install PyQt5
```
4. **联系技术支持**
- 提供错误信息截图
- 说明操作系统版本
- 提供Python版本信息
---
安装完成后就可以运行MetaCore PyQt5版本了🎉