pip默认下载源为python的官方源
https://pypi.org/
临时使用豆瓣源:
pip install pythonModuleName -i https://pypi.douban.com/simple
永久使用:
就要找到python的安装路径 然后找到D:\python\Lib\site-packages\pip_internal\commands下的search.py文件,发现里面有如下两行代码:
from pip._internal.models.index import PyPI
default=PyPI.pypi_url
可以看出来PyPI.pypi_url是从moudels模块里导入的,所有要找到moudels模板,该模块位于上一级目录,打开moudels里面的 index.py文件,可以看到
PyPI = PackageIndex(
''https://pypi.org/'', file_storage_domain='files.pythonhosted.org'
)
修改为
PyPI = PackageIndex(
'https://pypi.douban.com/simple', file_storage_domain='files.pythonhosted.org'
)