UV 使用
394 字
2 分钟
UV 使用
从 micromamba 转 uv 了
UV 优势
- 🚀 A single tool to replace
pip,pip-tools,pipx,poetry,pyenv,twine,virtualenv, and more. - ⚡️ 10-100x faster than
pip. - 🗂️ Provides comprehensive project management, with a universal lockfile.
- ❇️ Runs scripts, with support for inline dependency metadata.
- 🐍 Installs and manages Python versions.
- 🛠️ Runs and installs tools published as Python packages.
- 🔩 Includes a pip-compatible interface for a performance boost with a familiar CLI.
- 🏢 Supports Cargo-style workspaces for scalable projects.
- 💾 Disk-space efficient, with a global cache for dependency deduplication.
- ⏬ Installable without Rust or Python via
curlorpip. - 🖥️ Supports macOS, Linux, and Windows.
安装
# 安装brew install uv# mise# mise use -g uv@latest配置镜像源
$XDG_CONFIG_HOME/uv/uv.toml
[[index]]url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/"default = true迁移micromanba
# 迁移 micromamba 到 uvmicromamba list -e > requirements.txtuv pip install -r requirements.txt使用
Python versions
uv python install: Install Python versions.uv python list: View available Python versions.uv python find: Find an installed Python version.uv python pin: Pin the current project to use a specific Python version.uv python uninstall: Uninstall a Python version.
Scripts
uv run: Run a script.uv add --script: Add a dependency to a scriptuv remove --script: Remove a dependency from a script
Projects
uv init: Create a new Python project.uv add: Add a dependency to the project.uv remove: Remove a dependency from the project.uv sync: Sync the project’s dependencies with the environment.uv lock: Create a lockfile for the project’s dependencies.uv run: Run a command in the project environment.uv tree: View the dependency tree for the project.uv build: Build the project into distribution archives.uv publish: Publish the project to a package index.
Tools
uvx/uv tool run: Run a tool in a temporary environment.uv tool install: Install a tool user-wide.uv tool uninstall: Uninstall a tool.uv tool list: List installed tools.uv tool update-shell: Update the shell to include tool executables.
The pip interface
uv venv: Create a new virtual environment.uv pip install: Install packages into the current environment.uv pip show: Show details about an installed package.uv pip freeze: List installed packages and their versions.uv pip check: Check that the current environment has compatible packages.uv pip list: List installed packages.uv pip uninstall: Uninstall packages.uv pip tree: View the dependency tree for the environment.uv pip compile: Compile requirements into a lockfile.uv pip sync: Sync an environment with a lockfile.
Utility
uv cache clean: Remove cache entries.uv cache prune: Remove outdated cache entries.uv cache dir: Show the uv cache directory path.uv tool dir: Show the uv tool directory path.uv python dir: Show the uv installed Python versions path.uv self update: Update uv to the latest version.
文章分享
如果这篇文章对你有帮助,欢迎分享给更多人!
相关文章智能推荐
1
micromamba 工作环境配置
编程2024-04-23
2
重新认识 .gitignore:目录级规则与 .git/info/exclude
编程从目录级 .gitignore 的作用域、匹配优先级和常见陷阱出发,理解 Git 的忽略机制,并掌握 .git/info/exclude 的使用方法。
3
从 cc-connect 看 Codex CLI 的交互模式:stdin、stdio 与 HTTP
AI以 cc-connect 调用 Codex CLI 为例,拆解 exec、app-server、stdin/stdout 和 JSON-RPC,再和 HTTP 的通信模型做对照。
4
把 MCPHub 部署在 Homelab 上:统一管理 MCP 服务的实际体验
AI记录我把 Linear、Cloudflare、Bytebase 等 MCP 服务集中部署到 Homelab 后,解决多设备重复配置、token 分散和 MCP 地址过多问题的实际体验。
5
企业为什么需要 MCPHub:从统一接入到工具治理
企业AI从 MCP 服务集中接入、凭据治理、分组授权、监控审计和运维边界出发,讨论 MCPHub 在企业 AI 工具治理中的实际价值与局限。
随机文章随机推荐
