#工作记录
以下是一些国内常用的 pip 安装加速镜像源地址,综合多个来源整理而成,可有效提升下载速度:
主流镜像源地址
清华大学镜像源 https://pypi.tuna.tsinghua.edu.cn/simple 最常用的镜像源,覆盖全面且更新及时,支持 HTTPS。
阿里云镜像源 https://mirrors.aliyun.com/pypi/simple/ 速度快,稳定性高,适合企业及个人使用。
中国科学技术大学镜像源 https://pypi.mirrors.ustc.edu.cn/simple/ 教育站镜像,资源丰富,同步频率高。
豆瓣镜像源 https://pypi.douban.com/simple/ 兼容性好,但需注意部分包可能更新延迟,使用时需添加 --trusted-host 参数。
华为云镜像源 https://repo.huaweicloud.com/repository/pypi/simple/ 新晋镜像源,支持企业级需求。
腾讯云镜像源 https://mirrors.cloud.tencent.com/pypi/simple/ 适合腾讯云用户,速度稳定。
其他可用镜像源
华中理工大学:https://pypi.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org/
网易镜像源:https://mirrors.163.com/pypi/simple/。
使用方法
临时使用
在 pip install 命令后添加 -i 参数指定镜像源:
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
若镜像源为 HTTP 协议(如豆瓣源),需额外添加 --trusted-host:
pip install numpy -i https://pypi.douban.com/simple --trusted-host pypi.douban.com
永久配置
通过命令配置:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 手动修改配置文件
Linux/Mac:创建或编辑 ~/.pip/pip.conf
Windows:在 C:\Users\<用户名>\pip\pip.ini 中添加以下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
```:cite[3]:cite[5]:cite[7]。
注意事项
协议选择:优先使用 HTTPS 镜像源以避免安全警告。
更新 pip:若配置后速度未提升,建议先升级 pip:
python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple 更多镜像源状态及完整列表,可参考 清华大学镜像站帮助文档 或 阿里云镜像站。