国内镜像站资源汇总
> 把国外资源"搬"到国内,解决下载慢、连接超时的问题
---
一、AI 模型下载
1. HuggingFace 镜像站
- 地址: https://hf-mirror.com/
- 用途: 镜像 huggingface.co,下载 AI 模型和数据集
- 使用方法:
# 方法1: 网页下载
# 直接访问 hf-mirror.com 搜索模型
# 方法2: 设置环境变量 (推荐)
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download --resume-download gpt2 --local-dir gpt2
# 方法3: 使用 hfd 多线程下载工具
wget https://hf-mirror.com/hfd/hfd.sh
chmod a+x hfd.sh
export HF_ENDPOINT=https://hf-mirror.com
./hfd.sh gpt2
---
二、MacOS 开发环境
2. Homebrew 国内源配置
- 项目: https://gitee.com/cunkai/HomebrewCN
- 用途: 一键配置 MacOS Homebrew 国内源
- 使用方法:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
---
三、Python 包管理
3. pip 国内源配置
临时使用:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
永久配置:
# 清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 或阿里云
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
# 或中科大
pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/
4. conda 国内源配置
# 清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
---
四、Linux 系统源
5. apt 国内源配置 (Ubuntu/Debian)
一键换源脚本 (matools):
git clone https://github.com/matpool/matools.git
bash ./matools/mirrors/switch_apt_source.sh
手动配置:
# 备份原配置
cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 编辑 sources.list,替换为清华源 (Ubuntu 22.04)
sudo sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
sudo sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
# 更新
sudo apt update && sudo apt upgrade -y
---
五、综合换源工具
6. chsrc - 全平台一键换源 (强烈推荐)
- 项目: https://github.com/RubyMetric/chsrc
- 特点:
- 支持 65+ 目标 (apt/yum/pip/conda/ruby/npm等)
- 自动测速选择最快镜像
- 纯 C 编写,单文件无依赖
- 支持 Linux/macOS/Windows/BSD/Android
# 一键安装
curl https://chsrc.run/posix | bash
# 或手动下载
# 从 https://gitee.com/RubyMetric/chsrc/releases 下载对应平台二进制文件
使用:
# 查看支持的目标
chsrc list
# 一键测速+换源 (自动选择最快)
chsrc set pip
chsrc set apt
chsrc set conda
# 指定镜像
chsrc set pip tuna
# 查看当前源
chsrc get pip
# 恢复官方源
chsrc reset pip
7. matools - 机器学习环境配置
- 项目: https://github.com/matpool/matools
- 用途: 矩池云开源的 ML 环境配置工具
- 特点: 专注 apt/pip/conda 三件套
git clone https://github.com/matpool/matools.git
bash ./matools/mirrors/switch_apt_source.sh
bash ./matools/mirrors/switch_conda_source.sh
bash ./matools/mirrors/switch_pip_source.sh
8. LinuxMirrors - Linux 系统换源
- 项目: https://github.com/SuperManito/LinuxMirrors
- 官网: https://linuxmirrors.cn/
- 特点: 支持 25+ Linux 发行版,一键换源+Docker安装
# 一键换源
bash <(curl -sSL https://linuxmirrors.cn/main.sh)
# 一键安装 Docker
bash <(curl -sSL https://linuxmirrors.cn/docker.sh)
# 教育网用户
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --edu
# 海外用户
bash <(curl -sSL https://linuxmirrors.cn/main.sh) --abroad
支持的发行版: Ubuntu/Debian/CentOS/Fedora/Arch/Alpine/openEuler/Rocky/AlmaLinux/Deepin 等
---
六、GitHub 加速
9. ghfast.top - GitHub Clone 加速
- 地址: https://ghfast.top/
- 用途: 加速 GitHub 仓库克隆、Release 下载、Raw 文件
- 特点: 实测速度提升 50 倍 (60KB/s → 3MB/s)
# 原地址
git clone https://github.com/user/repo.git
# 加速地址
git clone https://ghfast.top/https://github.com/user/repo.git
# 下载 Raw 文件
wget https://ghfast.top/https://raw.githubusercontent.com/user/repo/main/file.txt
# 下载 Release
curl -O https://ghfast.top/https://github.com/user/repo/releases/download/v1.0/file.tar.gz
Git 全局配置 (自动替换):
git config --global url."https://ghfast.top/https://github.com/".insteadOf "https://github.com/"
---
七、快速选择指南
| 场景 | 推荐工具 | 命令 |
|---|---|---|
| 下载 AI 模型 | hf-mirror | export HF_ENDPOINT=https://hf-mirror.com |
| Python 包管理 | chsrc | chsrc set pip |
| Linux 系统源 | LinuxMirrors | bash <(curl -sSL https://linuxmirrors.cn/main.sh) |
| GitHub 克隆 | ghfast.top | git clone https://ghfast.top/https://github.com/... |
| 全能换源 | chsrc | chsrc set |
八、常用国内镜像站列表
PyPI 镜像
- 清华: https://pypi.tuna.tsinghua.edu.cn/simple
- 阿里云: https://mirrors.aliyun.com/pypi/simple/
- 中科大: https://pypi.mirrors.ustc.edu.cn/simple/
- 豆瓣: https://pypi.doubanio.com/simple/
Conda 镜像
- 清华: https://mirrors.tuna.tsinghua.edu.cn/anaconda
- 中科大: https://mirrors.ustc.edu.cn/anaconda
- 阿里云: https://mirrors.aliyun.com/anaconda
Ubuntu 镜像
- 清华: https://mirrors.tuna.tsinghua.edu.cn/ubuntu
- 阿里云: https://mirrors.aliyun.com/ubuntu
- 中科大: https://mirrors.ustc.edu.cn/ubuntu
GitHub 加速
- ghfast.top
- ghproxy.com
- gitclone.com
- kkgithub.com
参考链接
1. HuggingFace 镜像: https://hf-mirror.com/ 2. HomebrewCN: https://gitee.com/cunkai/HomebrewCN 3. matools: https://github.com/matpool/matools 4. chsrc: https://github.com/RubyMetric/chsrc 5. LinuxMirrors: https://github.com/SuperManito/LinuxMirrors 6. ghfast.top: https://ghfast.top/
---
*整理时间: 2026-03-28*
#镜像站 #国内源 #开发工具 #小凯