python安装

1.安装包下载
国内下载地址: https://mirrors.huaweicloud.com/python/
2.国内镜像源配置
按下Win+R打开运行窗口

  1. 输入%APPDATA%回车
  2. 新建pip文件夹(如果不存在的话)
  3. 在pip文件夹里新建pip.ini文件
    用记事本打开输入以下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn

uv安装配置

安装: pipx install uv 推荐pipx

在 Windows 系统上修改 UV 的下载源
在 Windows 系统上,可以通过以下几种方式修改 UV 的下载源:

  1. 通过环境变量修改
    UV 提供了 UV_DEFAULT_INDEX 环境变量来设置默认的包索引源。

设置方法:
打开 “此电脑” 或 “我的电脑”,右键点击选择 “属性”。
在弹出的窗口中选择 “高级系统设置”。
在 “系统属性” 窗口中,点击 “环境变量” 按钮。
在 “系统变量” 或 “用户变量” 中点击 “新建”:
变量名:UV_DEFAULT_INDEX
变量值:设置为你想要的镜像源地址,例如 https://pypi.tuna.tsinghua.edu.cn/simple
点击 “确定” 保存设置。

  1. 通过配置文件修改
    UV 支持在项目级别、用户级别和系统级别使用配置文件。

用户级别配置文件:
文件路径:%APPDATA%\uv\uv.toml

在该文件中添加以下内容:

[[index]]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
default = true 

项目级别配置文件:
文件路径:项目目录下的 pyproject.toml 或 uv.toml。

在 pyproject.toml 中添加:

[[tool.uv.index]]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
default = true

或在 uv.toml 中添加:

[[index]]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
default = true
  1. 通过命令行临时指定
    在命令行中运行 UV 命令时,可以直接指定镜像源:
uv add --default-index https://pypi.tuna.tsinghua.edu.cn/simple requests

pipx安装
https://blog.csdn.net/lvxinchun/article/details/146080460
参考

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐