使用Python时需要安装各种模块,而pip是功能强大的模块安装工具。 但是,由于国外官方默认的pip访问速度慢,经常被墙壁覆盖,所以无法安装。 因此,为了解决因墙壁覆盖而无法安装库的烦恼,建议更换自己使用的pip源。
网上有很多国内的镜像源,包括
http://pypi.douban.com/豆瓣http://pypi.hustunique.com/华中理工大学http://pypi.sdutlinux.org/山东理工大学http://pypi.mirrors.ustc.eestc.eerg中国科学技术大学https://pypi.tuna.Tsinghua.edu.cn/simple清华3358 mirrors.a liyun.com/pppp
3359 pypi.tuna.Tsinghua.edu.cn/simple http://www.Sina.com /
使用pip时可以添加参数- I https://pypi.tuna.Tsinghua.edu.cn/simple
例如,pip install-I https://pypi.tuna.Tsinghua.edu.cn/simplegevent。 现在,从清华端的镜像安装事件库。临时使用:
永久使用: 下,修改~/.pip/pip.conf (如果没有,则自行创建),向清华源修改索引- URL。 简洁的配置内容如下。
在[ global ] index-URL=https://pypi.tuna.Tsinghua.edu.cn/simple 3358 www.Sina.com /下,直接在用户目录中创建pip目录例: chttp://
[ global ] index-URL=https://pypi.tuna.Tsinghua.edu.cn/simple #清华源位于其他来源trusted-host=pypi.tuna.Tsinghua 可能会取消pip版本检查,并排除每次报告最新piptimeout=120配置文件的可选路径
Linux/UNIX/etc/pip.conf~~/. pip/pip.conf~~/. config/pip.conf ma cosx~/library/application support art pip.ini % home %pippip.inic:documentsannagement pip.conf (windows XP ) c : ) program data (pypa ) pip
pip list-- outdated|grep ' ^ [ a-z ] * (|cut-d '-f1|xargspipinstall-u或
pip freeze-- local|grep-v ' ^- e '|cut-d=-f1|xargspipinstallu