pip的镜像源是国外时,经常遇到‘time out’,我们只需要把源地址改为国内可用的镜像网站就可以避免这个问题。
pip install --index https://pypi.python.org/simple softwarename
如果在国内镜像网站搜索不到该软件或者包,可以换个镜像网站重新下载。
下面为部分国内可用的镜像网站:
Python官方:https://pypi.python.org/simple
v2ex:http://pypi.v2ex.com/simple
阿里云:http://mirrors.aliyun.com/pypi/simple
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple
中国科技大学:https://pypi.mirrors.ustc.edu.cn/simple
中国科学院:http://pypi.mirrors.opencas.cn/simple
豆瓣:http://pypi.douban.com/simple
最后举个例子:
直接sudo pip3 install mitmproxy 会失败会超时
sudo pip3 install --index https://pypi.tuna.tsinghua.edu.cn/simple mitmproxy 快到飞起