Linux command
uv 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Create a new Python project
uv init [project_name]
Add a dependency
uv add [package]
Remove a dependency
uv remove [package]
Sync dependencies
uv sync
Run a command
uv run [command]
Install a Python version
uv python install [3.12]
Create a virtual environment
uv venv
Install a tool globally
uv tool install [ruff]
说明
uv is an extremely fast Python package and project manager written in Rust. It replaces pip, pip-tools, pipx, poetry, pyenv, and virtualenv with a single unified tool. Projects are managed through pyproject.toml with dependencies locked in uv.lock. The uv sync command installs exact versions from the lock file, ensuring reproducible environments. UV manages Python versions directly—no need for pyenv. Use uv python install to download and manage multiple Python versions. The tool provides a pip-compatible interface (uv pip) for drop-in replacement in existing workflows, while offering project-based workflows for new projects.
参数
- init _name_
- Create a new Python project
- add _package_
- Add a dependency to pyproject.toml
- remove _package_
- Remove a dependency
- sync
- Sync dependencies with lock file
- lock
- Generate/update uv.lock file
- run _command_
- Run command in project environment
- python install _version_
- Install a Python version
- python list
- List installed Python versions
- venv _path_
- Create a virtual environment
- pip install _package_
- Install package (pip-compatible interface)
- tool install _tool_
- Install a CLI tool globally
- tool run _tool_
- Run a tool without installing
- --help, -h
- Show help
- --version, -V
- Show version
FAQ
What is the uv command used for?
uv is an extremely fast Python package and project manager written in Rust. It replaces pip, pip-tools, pipx, poetry, pyenv, and virtualenv with a single unified tool. Projects are managed through pyproject.toml with dependencies locked in uv.lock. The uv sync command installs exact versions from the lock file, ensuring reproducible environments. UV manages Python versions directly—no need for pyenv. Use uv python install to download and manage multiple Python versions. The tool provides a pip-compatible interface (uv pip) for drop-in replacement in existing workflows, while offering project-based workflows for new projects.
How do I run a basic uv example?
Run `uv init [project_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does init _name_ do in uv?
Create a new Python project