3

I am trying to build a python docker container.

Here is my 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"]

and in my req.ini file looks like this:

Flask fasttext gensim nltk scipy pandas numpy

But when I run docker build --tag python-app. , I get the following error:

#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

What am I doing wrong?

TheGainadl
  • 523
  • 1
  • 6
  • 14
  • Hi, based on the documentation, fastText requires pybind11 as well. can you try to add this package to your req.ini ? Documentation : https://fasttext.cc/docs/en/python-module.html – Oguzhan Aygun Feb 02 '22 at 11:45
  • I added pybind11 to req.ini but unfortunately, the error persists. – TheGainadl Feb 02 '22 at 11:54
  • 3
    Hi again, I took your Dockerfile and req.ini to reproduce the problem, In the error lines, it says, `RuntimeError: Unsupported compiler -- at least C++11 support is needed!` So, I added Dockerfile `RUN apt-get install build-essential -y` step and It is builded successfully. Can you try this? – Oguzhan Aygun Feb 02 '22 at 12:12
  • Yup, it worked. Thank your very much. Stack did not allowed me to post the whole error because I did not have a lot of text in the post, so I had to cut that part. – TheGainadl Feb 02 '22 at 12:21
  • No problem, glad it worked :) – Oguzhan Aygun Feb 02 '22 at 12:26

1 Answers1

1

You can add this to Dockerfile to get the C++11 package:

RUN apt-get update &&\
    apt-get install --no-install-recommends --yes build-essential
s510
  • 2,271
  • 11
  • 18