指定douban
pip3 install -r requirements.txt -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
临时使用
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy
这样就会从清华这边的镜像去安装numpy库。
永久修改
Linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
本文介绍如何通过指定豆瓣或清华大学提供的PyPI镜像源来加速pip安装Python包的过程。提供了临时更改及永久修改pip配置的方法,适用于Linux和Windows系统。
4013

被折叠的 条评论
为什么被折叠?



