skip to Main Content

I am trying to build an image for my flask server, I generated the requirements.txt using pipreqs.

The requirements.txt contains cryptography==2.8 and everytime the build fails on while trying to install this version. Not too sure why, it even shows that the version is right there.

Here is the docker build error

 22.90 ERROR: Could not find a version that satisfies the requirement cryptography==2.8 
(from versions: 0.1, 0.2, 0.2.1, 0.2.2, 0.3, 0.4, 0.5, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.6, 0.6.1, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.8.2, 0.9, 0.9.1, 0.9.2, 0.9.3, 1.0, 1.0.1, 1.0.2, 1.1, 1.1.1, 1.1.2, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.6, 1.7, 1.7.1, 1.7.2, 1.8, 1.8.1, 1.8.2, 1.9, 2.0, 2.0.1, 2.0.2, 2.0.3, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.2, 2.2.1, 2.2.2, 2.3, 2.3.1, 2.4, 2.4.1, 2.4.2, 2.5, 2.6, 2.6.1, 2.7, 2.8, 2.9, 2.9.1, 2.9.2, 3.0, 3.1, 3.1.1, 3.2, 3.2.1, 3.3, 3.3.1, 3.3.2, 3.4, 3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 35.0.0, 36.0.0, 36.0.1)
#8 22.90 ERROR: No matching distribution found for cryptography==2.8
#8 22.92 WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
#8 22.92 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
------
executor failed running [/bin/sh -c pip3 install -r requirements.txt]: exit code: 1

EDIT :
Even without copying any of the flask code, the following build fails

FROM python:3.8.10-alpine3.13
RUN pip install cryptography==2.8

Please have a look and let me know if more info is needed or where I am going wrong. Thanks

3

Answers


  1. Chosen as BEST ANSWER

    There appears to be a problem with the base image as pointed out by @Soheb, it works perfectly with python:3.8.10-slim-buster. Not too sure what was the issue with the previous base image though


  2. I think your problem in with alpine linux image, I mean the base image used for building python:3.9.10-alpine3.15 you should try to install cryptography manually by following the code mentioned below:

    RUN apk add --no-cache 
        libressl-dev 
        musl-dev 
        libffi-dev && 
    pip install --no-cache-dir cryptography==2.8 && 
    apk del 
        libressl-dev 
        musl-dev 
        libffi-dev
    

    Cryptography documentation also has the information as how to download it

    RUN apk add gcc musl-dev libffi-dev openssl-dev cargo

    Login or Signup to reply.
  3. The issue is that the alpine image does not have gcc installed as you can see in the complete error message (not shown in your question, but easily reproduced with docker):

    Unable to execute 'gcc': No such file or directory
    error: command 'gcc' failed with exit status 1
    

    Fix it by installing gcc and the dependencies of cryptography:

    FROM python:3.8.10-alpine3.13
    RUN apk add --no-cache 
        build-base 
        libressl-dev 
        musl-dev 
        libffi-dev
    RUN pip install cryptography==2.8 
    

    You might still wonder why you get the (confusing ) message:

    ERROR: Could not find a version that satisfies the requirement cryptography==2.8 
    (from versions: 0.1, 0.2, 0.2.1, 0.2.2, 0.3, 0.4, 0.5, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.6, 0.6.1, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.8.2, 0.9, 0.9.1, 0.9.2, 0.9.3, 1.0, 1.0.1, 1.0.2, 1.1, 1.1.1, 1.1.2, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.6, 1.7, 1.7.1, 1.7.2, 1.8, 1.8.1, 1.8.2, 1.9, 2.0, 2.0.1, 2.0.2, 2.0.3, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.2, 2.2.1, 2.2.2, 2.3, 2.3.1, 2.4, 2.4.1, 2.4.2, 2.5, 2.6, 2.6.1, 2.7, 2.8, 2.9, 2.9.1, 2.9.2, 3.0, 3.1, 3.1.1, 3.2, 3.2.1, 3.3, 3.3.1, 3.3.2, 3.4, 3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 35.0.0, 36.0.0, 36.0.1)
    

    The error message is simply stating the facts: pip could not find a version that

    1. fits your requirements
    2. Could be installed without error

    The only version that satisfied 1. (and was downloaded, see the complete log of the installation) did not staisfy 2. and was therefore discarded. Then the error is produced with a list of all versions that pip checked against condition 1. and 2., i.e. all versions on pypi that where candidates for your OS and python version

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search