pip源的更改:
pip的默认源在国外,pip install some_packages特别慢,经常会超时,导致安装失败;
pip 更换为国内的镜像
一:使用方法:
①临时使用:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 库名 #清华的大学的镜像
②永久修改:
(1)linux:
修改 ~/.pip/pip.conf (没有就创建一个), 内容如下:
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple12
(2)windows:
直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
二:常用镜像:
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
三:下载超时
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --default-timeout=100 库名
设置超时时间
本文介绍如何通过更改pip源为国内镜像来加速包的安装过程,包括临时和永久修改方法,并提供了清华、阿里云等多个镜像源选项。同时,讲解了如何设置下载超时时间以应对网络不稳定的情况。
7739

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



