明白了,你是想在国内下载 Python 及相关包,希望加速,使用国内镜像源。这里我给你整理最完整的指南,包括 Python 官方安装和 pip 国内镜像。
一、Python 官方下载(国内镜像加速)
1️⃣ 官方推荐安装
- Python 官网:https://www.python.org/downloads/
- 如果访问慢,可以使用 国内镜像下载:
| 镜像站 | 说明 | 链接 |
|---|---|---|
| 清华大学 TUNA 镜像 | 国内速度快 | https://mirrors.tuna.tsinghua.edu.cn/python/ |
| 中科大 USTC 镜像 | 国内速度快 | https://mirrors.ustc.edu.cn/python/ |
| 华为开源镜像 | 国内加速 | https://mirrors.huaweicloud.com/repository/python/ |
例如,你可以访问清华镜像:https://mirrors.tuna.tsinghua.edu.cn/python/
然后选择 Python 版本(Windows / macOS / Linux)下载安装。
二、pip 国内镜像加速
Python 包管理器 pip 下载包在国内经常慢,可以使用国内镜像:
1️⃣ 临时使用(单次命令)
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
-i指定镜像地址
2️⃣ 永久修改 pip 配置
Windows
- 找到
C:\Users\<用户名>\pip\pip.ini(没有就新建) - 写入:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
Linux / macOS
- 文件位置:
~/.pip/pip.conf(没有就新建) - 内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
以后用
pip install xxx就会自动使用清华镜像下载,速度快很多。
三、国内常用 Python 镜像源列表
| 镜像 | URL | 说明 |
|---|---|---|
| 清华大学 TUNA | https://pypi.tuna.tsinghua.edu.cn/simple | 速度快,更新及时 |
| 中科大 USTC | https://pypi.mirrors.ustc.edu.cn/simple | 稳定、更新及时 |
| 豆瓣 Douban | https://pypi.doubanio.com/simple/ | 曾经很常用,但 2022 后部分包更新慢 |
| 阿里云 | https://mirrors.aliyun.com/pypi/simple/ | 国内大厂镜像 |
| 华为开源镜像 | https://mirrors.huaweicloud.com/repository/pypi/simple | 国内速度快 |
四、Python 国内安装小技巧
- 优先用官方安装包 + 国内镜像加速 pip
- Windows 可选“Add Python to PATH”,方便命令行使用
- 推荐安装 Anaconda 或 Miniconda,国内镜像也可配置 conda 镜像:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
💡 总结:
- Python 安装包 → 用国内镜像下载,速度快
- pip 下载包 → 修改 pip 配置或临时指定镜像
- 国内镜像源常用:清华、中科大、阿里云、华为
发表回复