关键词:uv
Init Project
默认结构创建工程,生成 .toml 、 .python-version 、 README.md 等文件
Create Virtual Environment
在当前项目创建虚拟环境
- 可添加选项
--python 3.x.x 指定Python版本
Add Package To Dependencies
1 2
| uv add <package-name> uv add -r requirements.txt
|
Downloads Dependencies From requirements.txt
1
| uv pip install -r requirements.txt
|
Delete A Package
1
| uv remove <package-name>
|
Run A Python Script
这种执行会自动安装在 .toml 但未安装的依赖
Lock And Synchronize Project Dependencies
uv通过锁文件提供完全可重现的安装,运行uv sync命令复刻环境
uv.toml
uv.toml 位置大概在:C:\Users\<USERNAME>\AppData\Roaming\uv
可添加内容修改镜像源和依赖缓存位置:
1 2
| cache-dir = "D:/Cache/uv" index-url = "https://mirrors.aliyun.com/pypi/simple"
|