1

This is the current scenario, docker file, requirements and error. Any clue? This is a big python web application with flask that we would like to dockerize. The problem is happening during pandas-profiling lib dependency installation, specifically kiwisolver. See below.

Dockerfile:

FROM python:3.8-alpine
RUN adduser -D ddc-user
WORKDIR /ddc
COPY . /ddc
RUN python -m venv venv
RUN venv/bin/pip install --upgrade pip
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
     && apk --no-cache --update-cache add postgresql-dev g++ linux-headers gfortran libffi-dev openssl-dev gcc build-base bash libpng-dev openblas-dev wget freetype-dev python3-dev py3-pip \
     && ln -s /usr/include/locale.h /usr/include/xlocale.h \
     && pip install setuptools wheel \
     && pip install numpy pyyaml
RUN apk add --no-cache --virtual .build-deps gcc musl-dev
RUN pip install cython
RUN apk del .build-deps gcc musl-dev
RUN venv/bin/pip install -r requirements.txt
RUN chmod +x boot.sh
ENV FLASK_APP main.py
RUN chown -R ddc-user:users ./
USER ddc-user
EXPOSE 5000
ENTRYPOINT ["./boot.sh"]

Requirements.txt:

alembic==0.9.9
blinker==1.4
chardet==3.0.4
click==6.7
Flask==1.0.2
Flask-Dance==0.14.0
Flask-DebugToolbar==0.10.1
Flask-Login==0.4.1
Flask-Migrate==2.1.1
Flask-OAuth==0.12
Flask-OAuthlib==0.9.4
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
httplib2==0.11.3
idna==2.6
itsdangerous==0.24
Jinja2>=2.11.1
lazy==1.3
Mako==1.0.7
MarkupSafe==1.1.1
oauth2==1.9.0.post1
oauthlib==2.0.7
python-dateutil>=2.7.3
python-editor==1.0.3
requests==2.23.0
requests-oauthlib==0.8.0
SQLAlchemy==1.3.13
SQLAlchemy-Utils==0.33.2
urllib3==1.22
URLObject==2.4.3
Werkzeug==0.14.1
wincertstore==0.2
WTForms==2.1
Blueprint==3.4.2
google-cloud>=0.34.0
google-cloud-storage>=1.24.1
google-cloud-bigquery>=1.23.1
Flask-Bootstrap==3.3.7.1
six==1.13.0
flask-mail>=0.9.1
Markdown==2.6.8
itsdangerous==0.24
bleach==2.0.0
Flask-SSLify==0.1.5
gunicorn==19.7.1
gcsfs==0.3.0
cffi==1.13.2
pandas>=0.25.3
psycopg2==2.7.3
cloudstorage==0.10.0
vdm==0.15
xlrd>=1.0.0
schedule==0.6.0
Flask-HTTPAuth>=4.1.0
boto3==1.14.58
fsspec==0.8.2
pandas-profiling==2.9.0

Error during install kiwisolver dependency inside pandas-profiling:

Collecting kiwisolver>=1.0.1
  Downloading kiwisolver-1.2.0.tar.gz (52 kB)
    ERROR: Command errored out with exit status 1:
     command: /ddc/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rwhpliwg/kiwisolver/setup.py'"'"'; __file__='"'"'/t
mp/pip-install-rwhpliwg/kiwisolver/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close
();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-xjoogb9h
         cwd: /tmp/pip-install-rwhpliwg/kiwisolver/
    Complete output (44 lines):
    WARNING: The wheel package is not available.
      ERROR: Command errored out with exit status 1:
       command: /ddc/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-fjwbxpuf/cppy/setup.py'"'"'; __file__='"'"'/tmp/
pip-wheel-fjwbxpuf/cppy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(com
pile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-pyjyn3n5
           cwd: /tmp/pip-wheel-fjwbxpuf/cppy/
      Complete output (6 lines):

      usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help

      error: invalid command 'bdist_wheel'
      ----------------------------------------
      ERROR: Failed building wheel for cppy
    ERROR: Failed to build one or more wheels
    Traceback (most recent call last):
      File "/ddc/venv/lib/python3.8/site-packages/setuptools/installer.py", line 128, in fetch_build_egg
        subprocess.check_call(cmd)
      File "/usr/local/lib/python3.8/subprocess.py", line 364, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['/ddc/venv/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpnx5vz9py',
 '--quiet', 'cppy>=1.1.0']' returned non-zero exit status 1.
1
  • wheel needs to be installed inside the virtual env, as well. Commented Sep 30, 2020 at 16:38

2 Answers 2

2

You're mixing calls to the "system" pip/python and the copy in the virtual environment.

# In the "system" Python
RUN pip install setuptools wheel
# In the virtual environment
RUN venv/bin/pip install -r requirements.txt

Since a Docker image is already in an isolated environment separate from any particular host system's Python installation, it's typical to install things into the "system" Python inside an image, and not use a virtual environment at all. Delete the line that creates the virtual environment, and use just pip or python over venv/bin/... alternatives.

# Remove this line
# RUN python -m venv venv
# Use "pip", not "venv/bin/pip"
RUN pip install --upgrade pip
RUN pip install setuptools wheel
RUN pip install -r requirements.txt
Sign up to request clarification or add additional context in comments.

Comments

0

Your environment does not have access to an installation of wheel. You should be able to resolve this by adding the line:

RUN pip install wheel

to your dockerfile before you attempt to install your requirements file.

Edit: I missed that virtual environments were being utilized here. I would argue that using a virtual environment is unnecessary in this case unless the OP is using their docker instance to run multiple python applications in parallel. There are cases to be made for using this pattern, though that does not appear to be the case here. As such, my suggestion would be to do away with venv altogether and simply install all dependencies inside the docker instance python installation, which would convert every venv/bin/pip call to a simple pip call.

2 Comments

More precisely, RUN venv/bin/pip install wheel. Outside the venv it's already being installed.
I didn't see the usage of venv, arguably though, it's not necessary to use venv in this situation as docker containers are usually implemented for singular purposes and already handle isolation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.