临时镜像源
豆瓣源
-i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple
阿里源
-i https://mirrors.aliyun.com/pypi/simple
清华源
-i https://pypi.tuna.tsinghua.edu.cn/simple/
中科大源
-i https://pypi.mirrors.ustc.edu.cn/simple/
安装样例如下,将xxx换成对应的包
pip install xxx -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple
不被信任问题
若下载失败,可能由于经常使用代理导致镜像源不被信任的问题,可尝试在后面加入一段代码,例如豆瓣源加入
--trusted-host=pypi.douban.com/simple
其他源可相应替换为http://后面的部分
全局配置镜像源
- 两条命令分别是1. 配置镜像源;2. 信任镜像源
豆瓣源
pip config set global.index-url http://pypi.douban.com/simple
pip config set install.trusted-host pypi.douban.com
阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
pip config set install.trusted-host mirrors.aliyun.com
清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn
中科大源
pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple/
pip config set install.trusted-host pypi.mirrors.ustc.edu.cn
避免安装依赖
此方法可只安装指定包,不安装其他所有依赖
pip install xxx --no-deps
清楚pip缓存
每次pip安装下载的包都会放到缓存目录,多次安装中断会导致缓存爆满,运行以下命令可清楚pip缓存。
pip cache purge
997

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



