dashboard/PYTHON_ENV_SETUP_README.md
2025-06-09 14:59:40 +08:00

78 lines
1.8 KiB
Markdown
Raw Permalink 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.

# Python 环境配置指南
## 前提条件
- 已安装 CondaAnaconda 或 Miniconda
- Windows 操作系统
## 自动配置方法
1. 双击项目根目录中的 `setup_py_env.bat` 文件
2. 等待脚本完成环境配置和依赖安装
3. 环境配置完成后,窗口会显示使用说明
## 手动配置方法
如果自动配置方法不起作用,请按照以下步骤手动配置:
1. 打开命令提示符CMD或 PowerShell
2. 创建新的 Conda 环境:
```
conda create -n fast-dashboard-env python=3.11 -y
```
3. 激活环境:
```
conda activate fast-dashboard-env
```
4. 安装项目依赖:
```
cd 项目根目录
pip install -r backend/requirements.txt
```
## 运行后端服务器
1. 激活 Conda 环境(如果尚未激活):
```
conda activate fast-dashboard-env
```
2. 进入后端目录:
```
cd backend
```
3. 启动服务器:
```
uvicorn main:app --reload
```
4. 服务器将在 http://127.0.0.1:8000 启动
## 环境依赖列表
本项目使用以下 Python 库:
- fastapi==0.109.2
- uvicorn==0.27.1
- pydantic==2.6.1
- python-multipart==0.0.9
- python-jose==3.3.0
- passlib==1.7.4
- bcrypt==4.1.2
- requests==2.31.0
- beautifulsoup4==4.12.2
- sqlalchemy==2.0.26
- aiosqlite==0.19.0
- alembic==1.13.1
## 常见问题
1. **无法激活 Conda 环境**
- 确保已正确安装 Conda
- 尝试重新打开终端
- 运行 `conda init powershell`(如果使用 PowerShell
2. **依赖安装失败**
- 检查网络连接
- 尝试使用镜像源:`pip install -r backend/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple`
3. **启动服务器时出错**
- 确保所有依赖都已正确安装
- 检查 backend 目录下是否有 data 文件夹,如没有则创建