pip 是 python 必不可少的的包管理工具,但是要在国内用得爽,必须要配置镜像源。
有哪些镜像站可用,以及如何配置,网上都有很多分享了。
我常用的是 阿里云镜像站。
这里有一点比较麻烦的地方,就是是 Linux 和 Windows 环境下的 pip 配置文件的名字和位置都不同,经常混淆。
今天就教大家一招,快速搞定:
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set install.trusted-host mirrors.aliyun.com
执行完上面两条命令就可以啦。
pip config set 命令能自动把配置写入到用户对应的配置文件中:
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
命令虽然方便,但是参数格式复杂,记住不太容易,要是想改一下也挺麻烦,
所以我们进一步了解一下细节。
下面我以 Windows 系统为例,实际在 Linux 系统也是类似
查看配置
执行 pip config list 命令可以显示已经有了哪些配置:
pip config list
global.index-url='http://mirrors.aliyun.

最低0.47元/天 解锁文章
863





