用venv
1. 创建环境
cd path/to/your/project
python3 -m venv .venv
2. 激活环境
source .venv/bin/activate
3. 确认环境
which python
where python (windows)
4. 使用环境
pip install -r requirements.txt
5. 退出虚拟环境
deactivate
用poetry
pip install poetry
cd path/to/project
poetry init
poetry install
poetry shell
用Conda
conda create -n myproject python=3.11
conda activate myproject
pip install …