【教程】pip全局更换国内源(Windows & macOS)


?pip

pip is the package installer for Python. You can use pip to install packages from the Python Package Index and other indexes.

pip · PyPI


?pip国内源

阿里云
https://mirrors.aliyun.com/pypi/simple/
中国科技大学
https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban)
https://pypi.douban.com/simple/
清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学
https://pypi.mirrors.ustc.edu.cn/simple/

注意所有源已经全都更新为https


?pip全局更换国内源

Windows

pip config list -v

当前用户的pip配置文件为C:\Users\${username}\pip\pip.ini

我们把当前用户下的pip源更换为国内源


进入C:\Users\${username}\

新建文件夹pip

新建pip.ini

内容如下(更换为阿里云的源,根据需要自行更改)

[global]
index-url=https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

再次运行pip config list -v

更换源成功。


macOS

pip config list -v

当前用户的pip配置文件为/Users/${username}/.pip/pip.conf

我们把当前用户下的pip源更换为国内源

cd ~
mkdir .pip
cd .pip
vim pip.conf

内容如下(更换为阿里云的源,根据需要自行更改)

[global]
index-url=https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

再次运行pip config list -v

更换源成功。


?转载请注明出处

本文作者:双份浓缩馥芮白

原文链接:

版权所有,如需转载请注明出处。