设置pip的安装源

windows

一般有两个位置

  • C:\Users\<YourUsername>\.pip\pip.ini
  • C:\Users\<YourUsername>\AppData\Roaming\pip\pip.ini

linux

  • /etc/pip.conf
  • ~/.pip/pip.conf
  • ~/.pip.conf

内容

[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
trusted-host = pypi.tuna.tsinghua.edu.cn

[install]
use-mirrors = true 
mirrors = https://pypi.tuna.tsinghua.edu.cn/simple/
trusted-host = pypi.tuna.tsinghua.edu.cn
  1. [global]:这个部分定义了适用于pip的所有操作的全局设置。

    • timeout = 6000:将每个包安装尝试的超时设置为6000秒(或100分钟)。如果某个包的安装时间超过这个超时时间,安装将被视为失败。

    • index-url = https://pypi.tuna.tsinghua.edu.cn/simple/:这指定了pip在安装包时应该使用的默认包仓库的索引URL。在这里,它设置为https://pypi.tuna.tsinghua.edu.cn/simple/,这意味着pip将尝试从清华的PyPI镜像下载包。

    • trusted-host = pypi.tuna.tsinghua.edu.cn:此设置用于指示pypi.tuna.tsinghua.edu.cn域是可信任的,这意味着pip在该域上不会执行额外的SSL证书检查。

  2. [install]:这个部分提供了与包安装过程相关的设置。

    • use-mirrors = true:这启用了使用镜像进行包下载的功能。当设置为true时,pip将尝试使用镜像进行更快的包下载。

    • mirrors = https://pypi.tuna.tsinghua.edu.cn/simple/:这指定要用于包下载的镜像URL。在这里,再次设置为清华PyPI镜像。

    • trusted-host = pypi.tuna.tsinghua.edu.cn:这是特定于mirrors URL的可信任主机设置,表示pypi.tuna.tsinghua.edu.cn是镜像下载的受信任域,pip不会对该域执行额外的SSL证书检查。

常见源

posted @ 2023-07-24 12:16  厚礼蝎  阅读(142)  评论(0编辑  收藏  举报