镜像源简介
阿里云镜像源(mirrors.aliyun.com)是国内稳定可靠的PyPI镜像服务,通过替换默认下载源可显著提升Python包安装速度,特别适用于国内开发者环境。
命令行配置方法
推荐使用pip内置命令快速配置:
- 执行索引源设置命令:
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
- 添加信任主机参数:
pip config set install.trusted-host mirrors.aliyun.com
该配置会生成标准配置文件,兼容Windows/Linux/macOS系统。
手动配置方法
特殊环境下可通过编辑配置文件实现:
- Windows系统:创建
%USERPROFILE%\pip\pip.ini
文件,写入:[global] index-url = https://mirrors.aliyun.com/pypi/simple [install] trusted-host = mirrors.aliyun.com
- Linux/macOS:编辑
~/.pip/pip.conf
文件,内容同上
验证配置结果
执行安装命令测试镜像源是否生效:
pip install numpy --verbose
观察输出信息中的下载地址是否包含mirrors.aliyun.com域名。
常见问题
临时使用镜像源可在安装命令添加参数:pip install package -i https://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
本文由阿里云优惠网发布。发布者:编辑员。禁止采集与转载行为,违者必究。出处:https://aliyunyh.com/571603.html
其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。