目录

加速 pip 下载安装包的速度。下面使用的是来自于阿里云的镜像源:https://mirrors.aliyun.com/pypi/simple/

国内可用的pip镜像源

更新pip

# pip install --upgrade pip
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Requirement already up-to-date: pip in /usr/local/lib/python3.6/site-packages (20.2.4)

临时使用pip镜像

# pip install -i https://mirrors.aliyun.com/pypi/simple/ package

列出加载配置的路径和配置信息

# pip config list -v
For variant 'global', will try loading '/etc/xdg/pip/pip.conf'
For variant 'global', will try loading '/etc/pip.conf'
For variant 'user', will try loading '/root/.pip/pip.conf'
For variant 'user', will try loading '/root/.config/pip/pip.conf'
For variant 'site', will try loading '/usr/pip.conf'
global.index-url='https://mirrors.aliyun.com/pypi/simple/'
install.trusted-host='mirrors.aliyun.com'

设置默认镜像

# pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
Writing to /root/.config/pip/pip.conf

参考资料