pip config 主要包含以下子命令:set、get、edit、list、debug、unset。下面我們逐一介紹下它們。
pip config set
這個(gè)命令允許我們以name=value的形式配置某些項(xiàng),比如設(shè)置鏡像源:
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple
pip config get
這個(gè)命令允許我們查看某個(gè)配置項(xiàng)的值,比如查看鏡像源配置:
pip config get global.index-url
pip config edit
這個(gè)命令允許我們用一個(gè)編輯器打開配置文件進(jìn)行編輯,如果我們沒有指定--editor選項(xiàng),就會(huì)用VISUAL或者EDITOR環(huán)境變量的值作為編輯器,如下命令:
pip config --editor=vi edit
pip config list
這個(gè)命令以name=value的形式輸出當(dāng)前配置,假如我們已經(jīng)執(zhí)行了上面的pip config set命令,這時(shí)再執(zhí)行 pip config list就會(huì)輸出如下:
global.index-url='https://mirrors.cloud.tencent.com/pypi/simple'
pip config debug
這個(gè)命令列出各個(gè)配置文件位置及其內(nèi)容,在我系統(tǒng)上執(zhí)行pip config debug后輸出如下:
env_var:
env:
global:
/etc/xdg/pip/pip.conf, exists: False
/etc/pip.conf, exists: False
site:
/usr/pip.conf, exists: False
user:
/home/xxx/.pip/pip.conf, exists: False
/home/xxx/.config/pip/pip.conf, exists: True
global.index-url: https://mirrors.cloud.tencent.com/pypi/simple
global.hello: world
pip config unset
這個(gè)命令允許我們刪除一個(gè)配置,比如下面命令刪除了鏡像的配置:
pip config unset global.index-url
掌握了上述6個(gè)命令,你就學(xué)會(huì)了config的使用了,是不是很簡(jiǎn)單,歡迎評(píng)論交流!