Getting: "ERROR: Failed building wheel for xmlsec" when using docker to containerize flask app

7.1k views Asked by At

I am working to containerize my Flask app with docker, and am getting the following error when I run docker-compose build The app runs fine on my local machine. I have tried upgrading pip, using brew to uninstall/reinstall Libxmlsec1 and pkg-config, as well as using pip to uninstall/reinstall xmlsec. I am at a loss here and am not sure what steps I can take to get this to work. Any and all ideas appreciated, thank you.

#8 74.65   Building wheel for xmlsec (PEP 517): started
#8 75.30   Building wheel for xmlsec (PEP 517): finished with status 'error'
#8 75.30   ERROR: Command errored out with exit status 1:
#8 75.30    command: /usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpr1pesxvg
#8 75.30        cwd: /tmp/pip-install-eahoeaeb/xmlsec
#8 75.30   Complete output (22 lines):
#8 75.30   /tmp/pip-build-env-hk34bsbq/overlay/lib/python3.7/site-packages/setuptools/dist.py:645: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
#8 75.30     % (opt, underscore_opt))
#8 75.30   /tmp/pip-build-env-hk34bsbq/overlay/lib/python3.7/site-packages/setuptools/dist.py:645: UserWarning: Usage of dash-separated 'build-requires' will not be supported in future versions. Please use the underscore name 'build_requires' instead
#8 75.30     % (opt, underscore_opt))
#8 75.30   /tmp/pip-build-env-hk34bsbq/overlay/lib/python3.7/site-packages/setuptools/dist.py:645: UserWarning: Usage of dash-separated 'upload-dir' will not be supported in future versions. Please use the underscore name 'upload_dir' instead
#8 75.30     % (opt, underscore_opt))
#8 75.30   running bdist_wheel
#8 75.30   running build
#8 75.30   running build_py
#8 75.30   package init file 'src/xmlsec/__init__.py' not found (or not a regular file)
#8 75.30   creating build
#8 75.30   creating build/lib.linux-x86_64-3.7
#8 75.30   creating build/lib.linux-x86_64-3.7/xmlsec
#8 75.30   copying src/xmlsec/py.typed -> build/lib.linux-x86_64-3.7/xmlsec
#8 75.30   copying src/xmlsec/tree.pyi -> build/lib.linux-x86_64-3.7/xmlsec
#8 75.30   copying src/xmlsec/template.pyi -> build/lib.linux-x86_64-3.7/xmlsec
#8 75.30   copying src/xmlsec/constants.pyi -> build/lib.linux-x86_64-3.7/xmlsec
#8 75.30   copying src/xmlsec/__init__.pyi -> build/lib.linux-x86_64-3.7/xmlsec
#8 75.30   warning: build_py: byte-compiling is disabled, skipping.
#8 75.30   
#8 75.30   running build_ext
#8 75.30   error: xmlsec1 is not installed or not in path.
#8 75.30   ----------------------------------------
#8 75.30   ERROR: Failed building wheel for xmlsec
#8 75.30 Successfully built autocorrect autopep8 bs4 gunicorn MarkupSafe p5py pandocfilters simplegeneric sklearn tornado wrapt
#8 75.30 Failed to build xmlsec
#8 76.49 ERROR: Could not build wheels for xmlsec which use PEP 517 and cannot be installed directly

I am using the following requirements.txt file:

autocorrect==2.4.0
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
cycler==0.10.0
defusedxml==0.6.0
dnspython==2.1.0
Flask==1.1.2
gunicorn==20.1.0
idna==2.10
importlib==1.0.4
isodate==0.6.0
itsdangerous==1.1.0
Jinja2==2.11.3
joblib==1.0.1
kiwisolver==1.3.1
llvmlite==0.36.0
lxml==4.6.2
MarkupSafe==1.1.1
matplotlib==3.3.4
nltk==3.5
numba==0.53.1
numpy==1.20.1
onelogin==1.9.1
pandas==1.2.3
Pillow==8.1.2
pprintpp==0.4.0
pymongo==3.11.3
pyparsing==2.4.7
python-dateutil==2.8.1
python-dotenv==0.15.0
python3-saml==1.10.1
pytz==2021.1
regex==2020.11.13
requests==2.25.1
scikit-learn==0.24.1
scipy==1.6.1
six==1.15.0
sklearn==0.0
threadpoolctl==2.1.0
tqdm==4.59.0
urllib3==1.26.4
Werkzeug==1.0.1
xmlsec==1.3.9

Edit: I have since updated my docker file to grab all of the packages that Debian needs for xmlsec.

Dockerfile:
# Create our image based on Python 3.7.6
FROM python:3.7.6
RUN  apt-get update
RUN  apt-get -y install libxml2-dev libxmlsec1-dev libxmlsec1-openssl

# Expose ports
EXPOSE 5000

# Tell Python to not generate .pyc
ENV PYTHONDONTWRITEBYTECODE 1

# Turn off buffering
ENV PYTHONUNBUFFERED 1

# Install requirements using pip
ADD requirements.txt .
RUN python -m pip install -r requirements.txt

# Set working directory and addour Flask API files
WORKDIR /app
ADD . /app
1

There are 1 answers

0
AAber On BEST ANSWER

Change the top of the Docker file to:

FROM python:3.7.6
RUN  apt-get update
RUN  apt install -y xmlsec1