UV安装并设置国内源

文章目录

一、UV下载

1.官方一键安装

bash 复制代码
# On Windows.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh

2.github下载安装

国内网络问题无法下载解决方案

来到github下载自己对应系统的包:
https://github.com/astral-sh/uv/releases

我这里以linux为例选择x86_64下载地址为:
https://github.com/astral-sh/uv/releases/download/0.8.3/uv-x86_64-unknown-linux-gnu.tar.gz

下载到本地后上传到服务器并解压缩

将uv 、 uvx 放到 /usr/local/bin下即可!!!!!!

二、更换国内镜像源(加速下载)

方法1:临时环境变量(单次生效)

bash 复制代码
# 使用阿里云镜像源
export UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
uv pip install [包名]

# 或清华大学镜像源
export UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple/

方法2:永久配置(推荐)

创建或修改配置文件

在用户目录下创建 uv.toml 文件(路径参考):

  • Linux/macOS: ~/.config/uv/uv.toml
  • Windows: %APPDATA%\uv\uv.toml

添加国内镜像源

编辑文件内容如下:

bash 复制代码
[[index]]
url = "https://mirrors.aliyun.com/pypi/simple/"
default = true
# 或使用清华源
# url = "https://pypi.tuna.tsinghua.edu.cn/simple/"

方法3:命令行直接指定源

bash 复制代码
uv pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ [包名]

三、验证镜像源是否生效

bash 复制代码
# 查看当前配置
uv config get index.url

# 安装测试包(观察下载速度)
uv pip install numpy

常见镜像源地址

镜像名称 URL
阿里云 https://mirrors.aliyun.com/pypi/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
豆瓣 https://pypi.doubanio.com/simple/
华为云 https://repo.huaweicloud.com/repository/pypi/simple/

注意事项

  • 若同时使用 pip 和 uv,镜像源需分别配置(uv 不读取 pip 的配置)。
  • 更换源后如遇 SSL 错误,尝试将 http:// 替换为 https://。
  • 清除缓存命令:uv clean
相关推荐
Blossom.11819 小时前
Prompt工程与思维链优化实战:从零构建动态Few-Shot与CoT推理引擎
人工智能·分布式·python·智能手机·django·prompt·边缘计算
love530love21 小时前
Windows 11 下 Z-Image-Turbo 完整部署与 Flash Attention 2.8.3 本地编译复盘
人工智能·windows·python·aigc·flash-attn·z-image·cuda加速
MediaTea21 小时前
Python:模块 __dict__ 详解
开发语言·前端·数据库·python
jarreyer21 小时前
python,numpy,pandas和matplotlib版本对应关系
python·numpy·pandas
代码or搬砖1 天前
HashMap源码
开发语言·python·哈希算法
顽强卖力1 天前
第二章:什么是数据分析师?
笔记·python·职场和发展·学习方法
站大爷IP1 天前
Python实现Excel数据自动化处理:从繁琐操作到智能流程的蜕变
python
BBB努力学习程序设计1 天前
Python 进阶知识点精讲:上下文管理器(Context Manager)的原理与实战
python·pycharm
清水白石0081 天前
《深入 super() 的世界:MRO 与 C3 线性化算法的全景解析与实战指南》
python
大厂技术总监下海1 天前
Python 开发者的“新引擎”:Rust 编写的解释器,性能与安全兼得
python·开源