Python替换pypi阿里源

henry-0316 / 2024-10-05 / 原文

安装python解释器完成后,使用pip安装模块会遇到超时或者直接无法安装,可以设置使用国内的阿里源或者清华源,下面介绍下步骤
阿里源:pypi镜像源
清华源:pypi镜像源
python -m pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
python -m pip config set install.trusted-host mirrors.aliyun.com
windows:

C:\Users
$ python -m pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
Writing to C:\Users\xxx\AppData\Roaming\pip\pip.ini

C:\Users
$ python -m pip config set install.trusted-host mirrors.aliyun.com
Writing to C:\Users\xxx\AppData\Roaming\pip\pip.ini

linux:

root@ubuntu:~# python -m pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
Writing to /root/.config/pip/pip.conf
root@ubuntu:~# python -m pip config set install.trusted-host mirrors.aliyun.com
Writing to /root/.config/pip/pip.conf