1. 程式人生 > 實用技巧 >pip安裝時速度慢,怎麼辦?

pip安裝時速度慢,怎麼辦?

  如果你是一個python開發使用者,經常會用到pip去安裝一些模組或者工具,pip是很強大的模組安裝工具,但是由於國外官方pypi經常被牆,導致不可用,所以我們最好是將自己使用的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/

  使用舉例:

  比如我要安裝jupyter

  可以在使用pip的時候加引數-i https://pypi.tuna.tsinghua.edu.cn/simple

  #/usr/bin/pip install -i https://pypi.tuna.tsinghua.edu.cn/simplejupyterlab ,速度應該快了不少。



  

  永久修改,一勞永逸:

    Linux下,修改 ~/.pip/pip.conf (沒有就建立一個資料夾及檔案。資料夾要加“.”,表示是隱藏資料夾)

    內容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com