django - 使用 docker-compose up 时出现错误 RUN pip install -r requirements.txt
问题描述
我应该如何创建和安装 requirements.txt 文件以便在运行 docker-compose up 时能够正确读取它?
docker-compose up
使用通过创建的 requirements.txt运行时出现问题pip freeze > requirements.txt
要求.txt:
certifi==2021.5.30
charset-normalizer==2.0.3
Django==2.2.5
django-cors-headers==3.7.0
django-rest-framework==0.1.0
djangorestframework==3.12.4
idna==3.2
psycopg2 @ file:///C:/ci/psycopg2_1612298715048/work
python-decouple==3.4
pytz @ file:///tmp/build/80754af9/pytz_1612215392582/work
requests==2.26.0
sqlparse @ file:///tmp/build/80754af9/sqlparse_1602184451250/work
urllib3==1.26.6
wincertstore==0.2
我使用 anaconda 并pip
安装软件包
我的应用程序后端的 Dockerfile 尝试RUN pip install -r requirements.txt
出现以下错误。我可以感觉到@包出现错误,但对我来说最奇怪的是第一个(#17 1.299),因为它似乎只关注python-decouple==3.4。
=> ERROR [... 4/5] RUN pip install -r requirements.txt 1.8s
------
> [... 4/5] RUN pip install -r requirements.txt:
#17 1.299 DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).
#17 1.345 Collecting certifi==2021.5.30 (from -r requirements.txt (line 1))
#17 1.515 Collecting charset-normalizer==2.0.3 (from -r requirements.txt (line 2))
#17 1.541 Could not find a version that satisfies the requirement charset-normalizer==2.0.3 (from -r requirements.txt (line 2)) (from versions: 0.1a0, 0.1.1a0, 0.1.4b0, 0.1.5b0, 0.1.7, 0.1.8, 0.2.0, 0.2.1, 0.2.2, 0.2.3)
#17 1.544 No matching distribution found for charset-normalizer==2.0.3 (from -r requirements.txt (line 2))
#17 1.708 You are using pip version 19.0.3, however version 19.1.1 is available.
#17 1.708 You should consider upgrading via the 'pip install --upgrade pip' command.```
解决方案
TL;博士
替换charset-normalizer==2.0.3
为chardet>=3.0.2,<5;
requirements.txt 中的内容。您也可以选择一些特定版本来锁定版本。
我最近不得不建立一个旧的仓库,遇到了类似的问题
charset-normalizer
是由不再可能的请求安装的,但要探索它以前为什么/如何工作!
但是如果你检查requests==2.26.0
psf/requests:v2.26.0::seup.py的要求
对于小于 3 的 Python 版本,我们必须安装chardet>=3.0.2,<5;
insterd ofcharset_normalizer~=2.0.0
错误消息总是有帮助的,至少可以确定问题的根源
推荐阅读
- c++ - 同时写入内存中的一个字节
- c++ - 升级到 1.72.0 后 Boost 构建失败 - 两次相同的目标
- xslt-2.0 - format-number() 带有图片字符串 '#.##'
- bash - 如何将多个文件的内容附加到单个文件?
- c++ - 传递给另一个函数时获取数组的长度
- jquery - 如何在 n 秒后重试 AJAX 循环 n 次?
- windows - 尽管设置了 ImagePullPolicy=Never,但无法使用 kubectl 和 minikube 启动 pod
- python - 在 Python 中的函数之间返回
- karate - 空手道 - 无法与 pkcs12 密钥库和密码建立连接
- java - 来自 Java 服务的间歇性 UnknownHostException 的根本原因?