pip3换国内源

由于 python 自带的源有时候下载不了且速度慢,可以替换国内源

指令方式

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
pip config set install.trusted-host mirrors.aliyun.com

手动方式

  1. 获取pip的配置文件位置

pip -v config list

pip3 -v config list

For variant ‘global’, will try loading ‘/etc/xdg/xdg-ubuntu/pip/pip.conf’
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 ‘/home/tan/.pip/pip.conf’
For variant ‘user’, will try loading ‘/home/tan/.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’

我们操作第一个文件(不同系统目录不同文件后缀也不一致)即可

  1. 创建和修改pip配置文件
    cd /etc/xdg/xdg-ubuntu/
    sudo mkdir .pip
    sudo touch pip.conf

vim pip.conf

将下面的代码拷贝进去
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值