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
相关推荐
明知道的博客21 小时前
解决WSL环境下DeepSeek-OCR运行时内存不足问题
python·ocr·deepseek·deepseek-ocr
FreeCode1 天前
LangGraph1.0智能体开发:Graph API概念与设计
python·langchain·agent
test管家1 天前
如何在Python中使用SQLite数据库进行增删改查操作?
python
yangmf20401 天前
APM(三):监控 Python 服务链
大数据·运维·开发语言·python·elk·elasticsearch·搜索引擎
yangmf20401 天前
APM(二):监控 Python 服务
大数据·python·elasticsearch·搜索引擎
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2025-11-23)
python·开源·github·mcp
AI爱好者1 天前
WordPress保卫战:用Python分析日志并封禁恶意爬虫
python
nvd111 天前
Gidgethub 使用指南
开发语言·python
___波子 Pro Max.1 天前
Python模块导入详解与最佳实践
python
CNRio1 天前
ZUC国密算法深度研究:原理、实现与应用(Python、Rust)
python·算法·rust