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
相关推荐
chushiyunen21 小时前
python numpy包的使用
开发语言·python·numpy
小邓睡不饱耶21 小时前
Python多线程爬虫实战:爬取论坛帖子及评论
开发语言·爬虫·python
喵手21 小时前
Python爬虫实战:手把手教你如何采集开源字体仓库目录页(Google Fonts / 其他公开字体目录)!
爬虫·python·自动化·数据采集·爬虫实战·零基础python爬虫教学·开源字体仓库目录页采集
Chase_______21 小时前
【Python 基础】第2章:流程控制完全指南(if/match/while/for)
python
第一程序员21 小时前
Python高级特性详解:从基础到进阶
python·github
wzhidev21 小时前
04、Python核心数据类型详解:从一段诡异的调试说起
开发语言·python
wzhidev21 小时前
05、Python流程控制与函数定义:从调试现场到工程实践
linux·网络·python
Thomas.Sir21 小时前
第十一章:深入剖析 Prompt 提示工程
python·prompt
Fortune7921 小时前
用Pandas处理时间序列数据(Time Series)
jvm·数据库·python
2401_878530211 天前
高级爬虫技巧:处理JavaScript渲染(Selenium)
jvm·数据库·python