[英]Why does installing `install_requires` from setup.py using a dot “.” in the requirements.txt fail in Dockerfile?
I am trying to use the method described here我正在尝试使用此处描述的方法
Dockerfile文件
FROM python:3.8
COPY requirements.txt setup.py /tmp/
RUN pip3 install -r /tmp/requirements.txt \
&& rm /tmp/*
this fails with:这失败了:
Step 1/7 : FROM python:3.8
---> 79cc46abd78d
Step 2/7 : COPY requirements.txt setup.py /tmp/
---> Using cache
---> a50a0a8ecb06
Step 3/7 : RUN pip3 install -r /tmp/requirements.txt && rm /tmp/*
---> Running in c7d29bd8f23c
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml'
found.
I also tried commenting out the RUN
command, entering the container and running pip3 install -r /tmp/requirements.txt
manually.我还尝试注释掉
RUN
命令,进入容器并手动运行pip3 install -r /tmp/requirements.txt
。 This worked without error.这工作没有错误。
I have no idea what might be the issue here.我不知道这里可能有什么问题。
I figured it out:我想到了:
the dot .
点
.
is not relative to the requirements.txt
but rather to the current working directory.不是相对于
requirements.txt
而是相对于当前工作目录。 The reason it worked when I did it manually is, that I also mounted my workspace into a devcontainer and had my working directory in this workspace which also contained the setup.py
当我手动执行它时,它工作的原因是,我还将我的工作区安装到 devcontainer 中,并且在这个工作区中有我的工作目录,其中还包含
setup.py
The solution is thus to do something like this:因此,解决方案是做这样的事情:
WORKDIR /tmp
COPY requirements.txt setup.py ./
RUN pip3 install -r requirements.txt \
&& rm /tmp/*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.