我如何在我的Docker映像中安装dateinfer

发布于 2025-02-05 07:24:59 字数 1323 浏览 2 评论 0 原文

一些背景:我是了解Docker图像和容器以及如何编写Dockerfile的新手。我目前有一个Dockerfile,它可以通过PIP Install命令安装我想要的所有依赖项,因此,构建和部署图像非常简单。 但是我目前有一个新的要求使用DateInfer模块,并且无法通过PIP安装命令安装。 必须首先克隆仓库,然后必须安装,并且我很难通过Dockerfile实现这一目标。我现在一直关注的当前工作是运行容器并在目录中手动安装所有其他依赖项,并使用已安装的dateinfer进行更改。但是,这是一个非常繁琐且耗时的过程,我想通过在Dockerfile和我所有其他依赖项中提及它来实现同样的事情。

这就是我的dockerfile的样子:

FROM ubuntu:20.04
RUN apt update
RUN apt upgrade -y
RUN apt-get install -y python3
RUN apt-get install -y python3-pip
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
RUN apt-get install -y libenchant1c2a

RUN apt install git -y

RUN pip3 install argparse

RUN pip3 install boto3

RUN pip3 install numpy==1.19.1

RUN pip3 install scipy

RUN pip3 install pandas

RUN pip3 install scikit-learn
RUN pip3 install matplotlib

RUN pip3 install plotly

RUN pip3 install kaleido

RUN pip3 install fpdf

RUN pip3 install regex

RUN pip3 install pyenchant

RUN pip3 install openpyxl

ADD core.py /
ENTRYPOINT [ "/usr/bin/python3.8", "/core.py”]
                                  

因此,当我尝试像这样安装dateinfer时:

RUN git clone https://github.com/nedap/dateinfer.git
RUN cd dateinfer
RUN pip3 install .

它会引发以下错误: 错误:目录'。不可安装。尚未找到“ setup.py”和“ pyproject.toml”。 命令'/bin/sh -c pip3安装。返回一个非零代码:1

如何解决此问题?

Some background : I'm new to understanding docker images and containers and how to write DOCKERFILE. I currently have a Dockerfile which installs all the dependencies that I want through PIP install command and so, it was very simple to build and deploy images.
But I currently have a new requirement to use the Dateinfer module and that cannot be installed through the pip install command.
The repo has to be first cloned and then has to be installed and I'm having difficulty achieving this through a DOCKERFILE. The current work around I've been following for now is to run the container and install it manually in the directory with all the other dependencies and Committing the changes with dateinfer installed.But this is a very tedious and time consuming process and I want to achieve the same by just mentioning it in the DOCKERFILE along with all my other dependencies.

This is what my Dockerfile looks like:

FROM ubuntu:20.04
RUN apt update
RUN apt upgrade -y
RUN apt-get install -y python3
RUN apt-get install -y python3-pip
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
RUN apt-get install -y libenchant1c2a

RUN apt install git -y

RUN pip3 install argparse

RUN pip3 install boto3

RUN pip3 install numpy==1.19.1

RUN pip3 install scipy

RUN pip3 install pandas

RUN pip3 install scikit-learn
RUN pip3 install matplotlib

RUN pip3 install plotly

RUN pip3 install kaleido

RUN pip3 install fpdf

RUN pip3 install regex

RUN pip3 install pyenchant

RUN pip3 install openpyxl

ADD core.py /
ENTRYPOINT [ "/usr/bin/python3.8", "/core.py”]
                                  

So when I try to install Dateinfer like this:

RUN git clone https://github.com/nedap/dateinfer.git
RUN cd dateinfer
RUN pip3 install .

It throws the following error :
ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
The command '/bin/sh -c pip3 install .' returned a non-zero code: 1

How do I solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

客…行舟 2025-02-12 07:24:59

每个运行 dockerfile 在其自己的子壳中运行。如果您写下这样的东西:

RUN cd dateinfer

那是一个毫无疑问的:它启动一个新的外壳,更改目录,然后壳退出。下一个运行命令执行时,您又回到了/目录中。

解决此问题的最简单方法是将您的命令包括在单个运行语句中:

RUN git clone https://github.com/nedap/dateinfer.git && \
  cd dateinfer && \
  pip3 install .

实际上,您还可以使用其他 pip install install 命令从中受益;而不是一堆个人运行
命令,请考虑:

RUN pip3 install \
  argparse \
  boto3 \
  numpy==1.19.1 \
  scipy \
  pandas \
  scikit-learn \
  matplotlib \
  plotly \
  kaleido \
  fpdf \
  regex \
  pyenchant \
  openpyxl

这通常会更快,因为 pip 只需要解决
依赖性一次。

而不是在命令上单独指定所有软件包
行,您也可以将它们放入 sumplions.txt 文件中,然后
使用 PIP install -r Euncess.txt

Each RUN directive in a Dockerfile runs in its own subshell. If you write something like this:

RUN cd dateinfer

That is a no-op: it starts a new shell, changes directory, and then the shell exits. When the next RUN command executes, you're back in the / directory.

The easiest way of resolving this is to include your commands in a single RUN statement:

RUN git clone https://github.com/nedap/dateinfer.git && \
  cd dateinfer && \
  pip3 install .

In fact, you would benefit from doing this with your other pip install commands as well; rather than a bunch of individual RUN
commands, consider instead:

RUN pip3 install \
  argparse \
  boto3 \
  numpy==1.19.1 \
  scipy \
  pandas \
  scikit-learn \
  matplotlib \
  plotly \
  kaleido \
  fpdf \
  regex \
  pyenchant \
  openpyxl

That will generally be faster because pip only needs to resolve
dependencies once.

Rather than specifying all the packages individually on the command
line, you could also put them into a requirements.txt file, and then
use pip install -r requirements.txt.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文