我在django rest框架中有一个小项目,我想对它进行修改。在我的requirements.txt文件中有一个名为ruamel.yaml.clib==0.2.6的包。虽然下载所有其他需求是成功的,但当它尝试下载此包时会出现问题。
#11 208.5 Collecting ruamel.yaml.clib==0.2.6
#11 208.7 Downloading ruamel.yaml.clib-0.2.6.tar.gz (180 kB)
#11 217.8 ERROR: Command errored out with exit status 1:
#11 217.8 command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b8oectgw/ruamel-yaml-clib_517e9b3f18a94ebea71ec88fbaece43a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b8oectgw/ruamel-yaml-clib_517e9b3f18a94ebea71ec88fbaece43a/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-n2gr5j35
#11 217.8 cwd: /tmp/pip-install-b8oectgw/ruamel-yaml-clib_517e9b3f18a94ebea71ec88fbaece43a/
#11 217.8 Complete output (3 lines):
#11 217.8 sys.argv ['/tmp/pip-install-b8oectgw/ruamel-yaml-clib_517e9b3f18a94ebea71ec88fbaece43a/setup.py', 'egg_info', '--egg-base', '/tmp/pip-pip-egg-info-n2gr5j35']
#11 217.8 test compiling /tmp/tmp_ruamel_erx3efla/test_ruamel_yaml.c -> test_ruamel_yaml compile error: /tmp/tmp_ruamel_erx3efla/test_ruamel_yaml.c
#11 217.8 Exception: command 'gcc' failed: No such file or directory
#11 217.8 ----------------------------------------
#11 217.8 WARNING: Discarding https://files.pythonhosted.org/packages/8b/25/08e5ad2431a028d0723ca5540b3af6a32f58f25e83c6dda4d0fcef7288a3/ruamel.yaml.clib-0.2.6.tar.gz#sha256=4ff604ce439abb20794f05613c374759ce10e3595d1867764dd1ae675b85acbd (from https://pypi.org/simple/ruamel-yaml-clib/) (requires-python:>=3.5). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
#11 217.8 ERROR: Could not find a version that satisfies the requirement ruamel.yaml.clib==0.2.6 (from versions: 0.1.0, 0.1.2, 0.2.0, 0.2.2, 0.2.3, 0.2.4, 0.2.6)
#11 217.8 ERROR: No matching distribution found for ruamel.yaml.clib==0.2.6但是,当我下载这个软件包时没有问题,没有码头。有什么建议吗?
以下是Dockerfile:
FROM python:3-alpine
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN pip install -U pip setuptools wheel ruamel.yaml ruamel.yaml.clib==0.2.6
COPY ./requirements.txt .
RUN pip install --default-timeout=100 -r requirements.txt
# copy project
COPY . .这是撰写文件
version: '3.8'
services:
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/usr/src/app
ports:
- 8000:8000
env_file:
- ./.env.dev编辑
正如@Anthon在评论中提到的,这个问题与阿尔卑斯山有关。我在Dockerfile中使用了python:3.9-slim-buster,并解决了问题!
发布于 2021-09-22 15:50:05
我认为问题在于Dockerfile试图安装ruamel.yaml.clib的方式。应该使用pip来安装它(正如ruamel.yaml所记录的那样)。
我建议您将其从requirements.txt中删除,并显式地执行
pip install -U pip setuptools wheel ruamel.yaml.clib==0.2.6而是在你的Dockerfile中。这只会让您得到预编译的车轮,而不是尝试从源代码编译ruamel.yaml.clib,如果您没有安装C编译器,它将无法工作(这实际上是停靠者所抱怨的)。
我在多个Docker容器中成功地运行了ruamel.yaml.clib (但我从不使用requirements.txt)
发布于 2022-02-14 20:40:53
我看到OP已经从阿尔卑斯山转移到解决这个问题,但是出于任何需要/希望/希望留在高山上的原因,您可以安装gcc、musl-dev和python3-dev。
⋮
RUN apk add --no-cache gcc musl-dev python3-dev
⋮
RUN pip install ruamel.yaml.clib …https://stackoverflow.com/questions/69287269
复制相似问题