简体   繁体   English

为什么使用点“.”从 setup.py 安装 `install_requires` 在 Dockerfile 中的 requirements.txt 失败?

[英]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.

相关问题 setuptools setup.py 文件中 install_requires kwarg 的参考 requirements.txt - Reference requirements.txt for the install_requires kwarg in setuptools setup.py file Requirements.txt中的python版本与setup.py中的安装问题有关 - python version in requirements.txt issues with install requires in setup.py 如何从 setup.py 安装 `install_requires` 中列出的软件包而不安装主 package? - How to install packages listed in `install_requires` from setup.py without installing the main package? 如何从 setup.py install_requires 列表中安装 PyTorch 和相关工具? - How does one install PyTorch and related tools from within the setup.py install_requires list? 如何使用 install_requires 从 setup.py 安装 git+https:// - How to install git+https:// from setup.py using install_requires cffi (setup.py) 的构建轮...在 django 中从 requirements.txt 安装软件包时出错 - Building wheel for cffi (setup.py) ... error while installing the packages from requirements.txt in django Setup.py 从 requirements.txt 跳过开发依赖 - Setup.py skip dev dependency from requirements.txt requirements.txt 与 setup.py - requirements.txt vs setup.py 如何安装 github zip 文件与 pip 和 setup.py 来自 requirements.txt? - How can I install a github zip file with pip and setup.py from requirements.txt? 何时在setup.py中使用pip requirements文件与install_requires? - When to use pip requirements file versus install_requires in setup.py?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM