Docker中pip安装时报错的一个解决办法

在使用 docker 构建 django cms 应用时,出现了以下的错误信息:

$ git clone git@github.com:django-cms/django-cms-quickstart.git

$ cd django-cms-quickstart

$ docker compose build web

.....

=> ERROR [4/5] RUN pip install -r requirements.txt                                                             93.5s
------
 > [4/5] RUN pip install -r requirements.txt:
#0 8.385 WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))  after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/asgiref/
#0 13.94 WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/asgiref/
#0 20.00 WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))': /simple/asgiref/
#0 30.52 Collecting asgiref==3.5.2
#0 36.61   Downloading asgiref-3.5.2-py3-none-any.whl (22 kB)
#0 88.27 ERROR: Could not find a version that satisfies the requirement boto3==1.14.49 (from versions: none)
#0 88.27 ERROR: No matching distribution found for boto3==1.14.49
------
failed to solve: executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1

关键的错误信息,是 pip install 时报错: connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)'))'

这样的错误信息,如果是在操作系统下使用 pip install 时发生,我们通过配置修改 pip 源即可解决:

> pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

对于上面 docker 编译时出现的问题, 我们通过直接修改 Dockerfile  中的 pip install 指令来进行换源

RUN pip install -r requirements.txt  -i https://mirrors.aliyun.com/pypi/simple/

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ForestK

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值