建立虚拟环境¶
It is recommended to run your Python setup within a virtual environment. For framework development, uv creates and manages the virtual environment from the project lockfile. Tools such as pyenv or Anaconda can still provide the Python interpreter, but they do not need to create a separate project environment.
Python 版本¶
Flower requires at least Python 3.11.
Note
Due to a known incompatibility with ray, we currently recommend utilizing at most Python 3.11 for running Flower simulations.
Virtualenv with uv¶
From the repository root, run the bootstrap script:
./dev/bootstrap.sh
This creates framework/.venv with the repository's default Python version and
installs all framework dependencies from framework/uv.lock. To use a specific Python
version, pass it as the first argument:
./dev/bootstrap.sh 3.11.14
Activate the created virtual environment with:
source framework/.venv/bin/activate
You can also run uv directly from the framework directory:
cd framework
uv sync --python=3.11.14 --locked --all-extras --all-groups
Python Versions with Pyenv¶
If you use pyenv, install the Python version you want uv to use:
pyenv install 3.11.14
Then pass that version to the bootstrap script:
./dev/bootstrap.sh 3.11.14
Python Versions with Anaconda¶
If you prefer conda, create and activate a Python environment, then let uv create the framework project environment. See the conda installation guide for installation instructions.
conda create -n flower-3.11.14 python=3.11.14
conda activate flower-3.11.14
./dev/bootstrap.sh 3.11.14