pip安装python库时使用国内镜像资源加速下载过程

pip默认安装包是从网站https://pypi.org/simple下载,我们可以将其改成国内的镜像网站,加速下载过程,下面以安装numpy库为例:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy

下载其它库时,将numpy改成需要的库名即可。(使用pip、pip2 or pip3根据指向的python版本即可确定。)

在终端中输入pip install -help可以发现参数"-i"的作用:

Package Index Options:
  -i, --index-url <url>       Base URL of Python Package Index (default
                              https://pypi.org/simple). This should point to a
                              repository compliant with PEP 503 (the simple
                              repository API) or a local directory laid out in
                              the same format.

猜你喜欢

转载自www.cnblogs.com/wuliytTaotao/p/9457159.html