1. 程式人生 > >pip3 list --outdate無法載入及更新源

pip3 list --outdate無法載入及更新源

最近想更新一下python的第三方庫

輸入

pip install --outdate

但是半天沒反應,這可能是pip源的問題。
因為pip預設是使用國外的源,在國內訪問的話會非常慢。
這時候就需要更改預設源為國內源

pip國內的一些映象

這裡我使用的是清華的源,大家可以根據自己的情況合適選擇源(這裡是臨時修改源)

pip list --outdate -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

Linux:
linux下,修改 ~/.pip/pip.conf (沒有就建立一個), 修改 index-url至tuna,內容如下:

 [global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple

還可以修改為多個源:
輸入: vim .pip/pip.conf

內容如下:

[global]
index-url=http://pypi.douban.com/simple
extra-index-url=http://mirrors.aliyun.com/pypi/simple/
extra-index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
extra-index-url=http://pypi.mirrors.ustc.edu.cn/simple/

[install]
trusted-host=pypi.douban.com
trusted-host=mirrors.aliyun.com
trusted-host=pypi.tuna.tsinghua.edu.cn
trusted-host=pypi.mirrors.ustc.edu.cn

Mac os:
在終端進入目錄:

                       cd ~/

如果沒有 .pip 資料夾,那麼就要新建這個資料夾,

                   mkdir .pip

然後在.pip 資料夾內新建一個檔案

                     touch pip.conf

內容如下:

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

如果想要改為預設源

改為原來的配置就行了

然後就可以了

在這裡插入圖片描述