Windows下pip使用豆瓣的软件镜像源
2017-03-26 本文已影响464人
拎壶冲da
使用easy_install和pip安装第三方库的时候,原理都是从Python的官方源https://pypi.python.org/pypi下载到本地,然后解包安装。不过因为某些原因,访问官方的pypi不稳定,很慢甚至有时候出现无法访问。
因此,有时候为了追求速度,国内的Pythoner很多采用豆瓣的源,使用豆瓣的源安装包可以采用下面的两种方式:
1、临时使用
在命令行中添加参数,可以让pip
从指定的豆瓣源中安装软件
<pre>
pip install pythonModuleName -i https://pypi.douban.com/simple
</pre>
2、长久使用
找到python的安装路径,找到Lib/site-packages/pip/commands
下的search.py文件

打开,会发现default=PyPI.pypi_url

这里的PyPI.pypi_url
是从from pip.models import PyPI
这里导入的,进入到models
,

打开index.py
,将PyPI的路径改为豆瓣源路径即可
