python在線安裝庫時會較慢,那是因為python的默認鏡像源在國外,因此會慢;而國內有很多可以用的python鏡像源,將python鏡像源更改為國內的,則可以大大加快python庫的安裝速度。
1.Python鏡像源集合
阿里雲 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/
華中理工大學 http://pypi.hustunique.com/simple/
山東理工大學 http://pypi.sdutlinux.org/simple/
加利福尼亞大學 https://www.lfd.uci.edu/~gohlke/pythonlibs/
2.Pyhton鏡像臨時更換方法
- 臨時更換:可以在使用pip安裝庫的時候加參數-i https://pypi.tuna.tsinghua.edu.cn/simple
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple
- 永久更換——windows環境,在user目錄中創建一個pip目錄,如:C:\Users(用戶)\xx\pip,新建文件pip.ini,內容如下
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
參考博客:Python鏡像源集合+鏡像源更改方法