前言
python的pip安裝庫很慢,因為它默認的鏡像源是國外的,將鏡像源換成國內的就很快了,下面介紹怎么更換國內鏡像源。
正文
國內比較好的鏡像源有以下這些:
- 阿里雲 http://mirrors.aliyun.com/pypi/simple/
- 中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
- 豆瓣(douban) http://pypi.douban.com/simple/
- 清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
- 中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
如果是想臨時更換鏡像源,通過以下命令:
pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple
在后面-i接鏡像源就可以了。
臨時更換比較麻煩,建議一勞永逸,把國內的鏡像源設成默認就可以了,不過要升級 pip 到最新的版本 (>=10.0.0) 。
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple