当前位置: 首页 > news >正文

Python 包管理工具 uv

uv 是由 Rust 编写的超快速 Python 包安装器和解析器,由创建了流行的 Rust 包管理器 Cargo 的团队开发。它旨在成为未来 pip 和 pip-tools 的现代替代品。

主要特性

  1. 极快的性能​​:比 pip 快 10-100 倍
  2. 现代功能​​:
    • 支持最新的 Python 包标准
    • 内置虚拟环境管理
    • 支持锁定文件
  3. ​​兼容性​​:
    • 兼容现有的 pip 和 pip-tools 工作流
    • 支持 requirements.txt 和 pyproject.toml

1

uv 安装

$powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Downloading uv 0.7.19 (x86_64-pc-windows-msvc)
Installing to C:\Users\user\.local\binuv.exeuvx.exeuvw.exe
everything's installed!To add C:\Users\user\.local\bin to your PATH, either restart your shell or run:set Path=C:\Users\user\.local\bin;%Path%   (cmd)$env:Path = "C:\Users\user\.local\bin;$env:Path"   (powershell)

主要功能

uv -h
An extremely fast Python package manager.Usage: uv [OPTIONS] <COMMAND>Commands:run      Run a command or scriptinit     Create a new projectadd      Add dependencies to the projectremove   Remove dependencies from the projectversion  Read or update the project's versionsync     Update the project's environmentlock     Update the project's lockfileexport   Export the project's lockfile to an alternate formattree     Display the project's dependency treetool     Run and install commands provided by Python packagespython   Manage Python versions and installationspip      Manage Python packages with a pip-compatible interfacevenv     Create a virtual environmentbuild    Build Python packages into source distributions and wheelspublish  Upload distributions to an indexcache    Manage uv's cacheself     Manage the uv executablehelp     Display documentation for a command

Python 版本管理

Commands:list       List the available Python installationsinstall    Download and install Python versionsupgrade    Upgrade installed Python versions to the latest supported patch release (requires the `--preview` flag)find       Search for a Python installationpin        Pin to a specific Python versiondir        Show the uv Python installation directoryuninstall  Uninstall Python versions

包安装

uv pip install flask  # 安装单个包
uv pip install -r requirements.txt  # 从文件安装

虚拟环境管理

uv venv .venv  # 创建虚拟环境
source .venv/bin/activate  # 激活虚拟环境

依赖解析

uv pip compile pyproject.toml -o requirements.txt  # 生成锁定文件
uv pip sync requirements.txt  # 同步依赖

uv 目前仍处于积极开发阶段,但已经可以用于生产环境,特别适合需要频繁安装Python包或大型项目的开发者。

相关链接

https://docs.astral.sh/uv/

http://www.lryc.cn/news/582088.html

相关文章:

  • 【C语言进阶】数据是如何存储的?
  • Web后端开发-请求响应
  • 国产CAD皇冠CAD(CrownCAD)建模教程:哈雷摩托车发动机零件
  • [论文阅读] 人工智能 | 读懂Meta-Fair:让LLM摆脱偏见的自动化测试新方法
  • 【mini-spring】【更新中】第一章 IOC与Bean源码及思路解析
  • IT 与动环一体化运维的技术融合实践
  • MySQL Galera Cluster企业级部署
  • 力扣_链表(前后指针)_python版本
  • verilog中timescale指令的使用
  • 零知开源——STM32F4结合BMP581气压传感器实现ST7789中文显示教程
  • centos stream 10设置本地网络
  • 沙箱逃逸漏洞
  • 音频信号的预加重:提升语音清晰度
  • OpenCV 人脸分析------面部关键点检测类cv::face::FacemarkLBF
  • 使用ansible的角色实现批量安装nginx服务
  • 图像处理基础:镜像、缩放与矫正
  • 《声音的变形记:Web Audio API的实时特效法则》
  • 【论文撰写】如何把AI生成的文本公式复制在word中,完整的复制公式,拷贝豆包生成的公式
  • 音频流媒体技术选型指南:从PCM到Opus的实战经验
  • 在linux 上使用tcpdump监听http 端口的报文并分析
  • C++之string类的实现代码及其详解(中)
  • 项目中多个模块都需要引入外部jar
  • Spring Boot项目初始化:官方与阿里云服务地址对比指南
  • ExcelJS 完全指南:专业级Excel导出解决方案
  • vue3 字符包含
  • 暑假Python基础整理 -- Python语言基础
  • 初识Neo4j之Cypher(三)
  • 企业级视频链接的技术实现与安全性策略
  • [免费]基于Python豆瓣电影数据分析及可视化系统(Flask+echarts+pandas)【论文+源码+SQL脚本】
  • 部署NextCloud AIO + Frp + nginx-proxy-manager内网穿透私有云服务