码迷,mamicode.com
首页 > 其他好文 > 详细

让PIP源使用国内镜像,提升下载速度和安装成功率。

时间:2019-03-14 20:08:54      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:domain   hosted   ted   python开发   镜像   使用   山东   global   理工大学   


对于Python开发用户来讲,PIP安装软件包是家常便饭。但国外的源下载速度实在太慢,浪费时间。而且经常出现下载后安装出错问题。所以把PIP安装源替换成国内镜像,可以大幅提升下载速度,还可以提高安装成功率。

国内源:

新版ubuntu要求使用https源,要注意。

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/ 

豆瓣:http://pypi.douban.com/simple/

临时使用:

可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

 

 

永久修改,一劳永逸:

Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)



例如: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’
)
保存文件即可.

让PIP源使用国内镜像,提升下载速度和安装成功率。

标签:domain   hosted   ted   python开发   镜像   使用   山东   global   理工大学   

原文地址:https://www.cnblogs.com/wdz1226/p/10532941.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!