无法在Docker容器上安装fasttext

3

我正在尝试构建一个Python Docker容器。

这是我的Dockerfile:

# syntax=docker/dockerfile:1
FROM python:3.8-slim
WORKDIR /src
COPY req.ini req.ini
RUN apt-get update
RUN pip install --upgrade pip setuptools wheel
RUN pip install -r req.ini
COPY . .
CMD ["python3","flask","run","--host=0.0.0.0"]

我的req.ini文件看起来像这样:

Flask fasttext gensim nltk scipy pandas numpy

但是当我运行docker build --tag python-app时,我会收到以下错误:

#15 11.25   Building wheel for fasttext (setup.py): finished with status 'error'
#15 11.26   error: subprocess-exited-with-error
#15 11.26
#15 11.26   × python setup.py bdist_wheel did not run successfully.
#15 11.26   │ exit code: 1
#15 11.26   ╰─> [42 lines of output]

#15 11.26   ERROR: Failed building wheel for fasttext
#15 11.26   Running setup.py clean for fasttext
#15 11.38 Failed to build fasttext
#15 15.60   Running setup.py install for fasttext: finished with status 'error'
#15 15.61   error: subprocess-exited-with-error
#15 15.61
#15 15.61   × Running setup.py install for fasttext did not run successfully.
#15 15.61   │ exit code: 1
#15 15.61   ╰─> [46 lines of output]
#15 15.61       /usr/local/lib/python3.8/site-packages/setuptools/dist.py:731: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead

#15 15.61 × Encountered error while trying to install package.
#15 15.61 ╰─> fasttext
#15 15.61
#15 15.61 note: This is an issue with the package mentioned above, not pip.

------
executor failed running [/bin/sh -c pip install -r req.ini]: exit code: 1

我做错了什么?


根据文档,fastText 还需要 pybind11。你能否尝试将此软件包添加到你的 req.ini 中呢? 文档链接:https://fasttext.cc/docs/en/python-module.html - Oguzhan Aygun
我已经将pybind11添加到req.ini中,但不幸的是,错误仍然存在。 - TheGainadl
3
您好,我已经拿到了您的Dockerfile和req.ini来复现问题。在错误的行中,它说:“RuntimeError:不支持的编译器--至少需要C++11支持!"因此,我添加了Dockerfile中的步骤“RUN apt-get install build-essential -y”,并且它成功构建了。您可以尝试一下这个方法吗? - Oguzhan Aygun
好的,它起作用了。非常感谢您。由于我的帖子中没有太多文本,因此Stack不允许我发布整个错误,所以我不得不剪切那部分。 - TheGainadl
没问题,很高兴它起作用了 :) - Oguzhan Aygun
1个回答

1

您可以将以下内容添加到 Dockerfile 中以获取 C++11 包:

RUN apt-get update &&\
    apt-get install --no-install-recommends --yes build-essential

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接