pip 源切换至国内镜像
使用 pip 安装软件时,使用国内镜像可以大大提高下载速度
常用国内镜像:
https://pypi.tuna.tsinghua.edu.cn/simple/ # 清华大学
https://mirrors.aliyun.com/pypi/simple/ # 阿里云
https://pypi.douban.com/simple/ # 豆瓣
https://pypi.mirrors.ustc.edu.cn/simple/ # 中国科学技术大学
https://pypi.hustunique.com/ # 华中科技大学
临时使用方法如下:
pip install 添加 -i 参数指定源
示例:
通过清华镜像安装 pip:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ pytest-html
如果要永久使用的话,需要如下在用户的根目录下创建 .pip 文件夹,新建 pip.conf 文件
示例:
mkdir .pip # 创建 .pip
cd .pip # 进入.pip
vim pip.conf
在文件中写入要使用的镜像
示例:
使用清华镜像
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn