对于Python开发用户来说,PIP安装软件包是屡见不鲜。但国外的源下载速度实在太慢,浪费时间。并且常常出现下载后安装出错问题。因此把PIP安装源替换成国内镜像,能够大幅提高下载速度,还能够提升安装成功率。python
国内源:
新版ubuntu要求使用https源,要注意。linux
清华:https://pypi.tuna.tsinghua.edu.cn/simpleubuntu
阿里云:http://mirrors.aliyun.com/pypi/simple/windows
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/dom
华中理工大学:http://pypi.hustunique.com/ide
山东理工大学:http://pypi.sdutlinux.org/ 阿里云
豆瓣:http://pypi.douban.com/simple/url
临时使用:
能够在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simplespa
永久修改,一劳永逸:
Linux下,修改 ~/.pip/pip.conf (没有就建立一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)code
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。
内容以下:
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple [install] trusted-host=mirrors.aliyun.com
windows下
找到你python的安装目录下的文件
注意虚拟环境的话还须要改虚拟环境里的index.py
例如个人D:\soft\PY\Lib\site-packages\pip_internal\models下面的index.py文件里面将PYPI的值改成你所须要的源便可,例如改成清华的源。PyPI = PackageIndex(‘https://pypi.tuna.tsinghua.edu.cn/simple’, file_storage_domain=‘files.pythonhosted.org’)保存文件便可.