Environment:666ghj BettaFish Python 3 10 Plus
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, Runtime |
| Last Updated | 2026-10-08 21:30 GMT |
Overview
Python 3.10+ runtime environment with modern typing, async support, and compatibility with all BettaFish engine packages.
Description
This environment provides the Python runtime required by all BettaFish components. The project uses modern Python features including `typing.Optional`, `Literal` type hints, `from __future__ import annotations`, and f-strings. The codebase targets Python 3.10+ as evidenced by the use of `match` statements, `|` union type syntax, and the `weasyprint` package which supports Python 3.9–3.13. Conda deployment is recommended on Windows.
Usage
Use this environment for all BettaFish components, including Flask web server, Streamlit UIs, agent orchestrators, and report generation pipeline. It is the base runtime prerequisite.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, Windows | Windows requires Conda recommended |
| Hardware | 4GB+ RAM | 8GB+ recommended for ML workloads |
| Disk | 5GB+ | For Python packages and Playwright browsers |
Dependencies
System Packages
- Python 3.10+ (3.11/3.12 recommended)
- Conda (recommended for Windows; see `requirements.txt` header)
Python Packages
- `flask` == 2.3.3
- `flask-socketio` == 5.3.6
- `streamlit` == 1.28.1
- `eventlet` == 0.33.3
- `openai` >= 1.3.0
- `pydantic` == 2.5.2
- `pydantic-settings` == 2.2.1
- `loguru` >= 0.7.0
- `json-repair` == 0.53.0
- `aiofiles` == 23.2.1
Credentials
No credentials required for the runtime itself. See individual engine environment pages for API keys.
Quick Install
# Create conda environment (recommended on Windows)
conda create -n bettafish python=3.11
conda activate bettafish
# Install all dependencies
pip install -r requirements.txt
Code Evidence
UTF-8 environment setup from `app.py:9-11`:
os.environ['PYTHONIOENCODING'] = 'utf-8'
os.environ['PYTHONUTF8'] = '1'
os.environ['PYTHONUNBUFFERED'] = '1' # 禁用Python输出缓冲,确保日志实时输出
Requirements header noting Windows + Conda from `requirements.txt:1-4`:
# Weibo舆情分析多智能体系统依赖包
# 适用于Windows环境 + Conda部署
WeasyPrint Python version support from `requirements.txt:61`:
weasyprint>=60.0 # PDF导出,支持Python 3.9-3.13
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ImportError: cannot import name 'Literal' from 'typing'` | Python < 3.8 | Upgrade to Python 3.10+ |
| `UnicodeDecodeError` on Windows | Console encoding mismatch | Set `PYTHONUTF8=1` (done automatically in `app.py`) |
| `ModuleNotFoundError: No module named 'flask_socketio'` | Dependencies not installed | Run `pip install -r requirements.txt` |
Compatibility Notes
- Windows: Conda environment recommended. Set `PYTHONUTF8=1` for UTF-8 support.
- macOS: Apple Silicon (M1/M2) supported. Set `DYLD_LIBRARY_PATH` for PDF export.
- Docker: Official Docker image `ghcr.io/666ghj/bettafish:latest` includes all dependencies.
- Python 3.13: Supported by weasyprint >= 60.0. May require updated package versions.
Related Pages
- Implementation:666ghj_BettaFish_DeepSearchAgent_init
- Implementation:666ghj_BettaFish_Clustering_and_Sampling
- Implementation:666ghj_BettaFish_FileCountBaseline_initialize
- Implementation:666ghj_BettaFish_Flask_SocketIO_App
- Implementation:666ghj_BettaFish_HTMLRenderer_render
- Implementation:666ghj_BettaFish_DocumentComposer_build_document
- Implementation:666ghj_BettaFish_LogMonitor_start_monitoring
- Implementation:666ghj_BettaFish_forum_reader_get_latest
- Implementation:666ghj_BettaFish_parse_template_sections
- Implementation:666ghj_BettaFish_QWEN3_MODELS_config