Install using pip requires rust

Description of the issue

Installing docker-compose with pip as per the instructions from the docs fails with

  error: Can not find Rust compiler
  ERROR: Failed building wheel for cryptography

It looks like the cryptography dependency (now?) requires rust.

Of course it would not be a problem to install the rust compiler but then it should at least be mentioned in the docs. On the other hand I don’t think this is intentional, therefore the issue.

Context information (for bug reports)

Output of docker version

Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:45:36 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
  Version:          19.03.12
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       48a66213fe
  Built:            Mon Jun 22 15:44:07 2020
  OS/Arch:          linux/amd64
  Experimental:     false
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
  Version:          0.18.0
  GitCommit:        fec3683

Steps to reproduce the issue

Dockerfile to reproduce:

FROM docker:19-dind

RUN apk add py-pip python3-dev libffi-dev openssl-dev gcc libc-dev make curl && \
  pip install docker-compose

Observed result

Building the image fails with the mentioned error message.

Expected result

Building the image works without issues.

Stacktrace / full error message

Additional information

Installing in a docker image

3 thoughts on “Install using pip requires rust

  1. I had the same issue. I just added this export line before I install docker-compose with pip.


    This is already suggested in the build failure message. This worked for me as I only build and test my project with docker-compose in alpine Linux. I don’t run with docker-compose, I do that with docker run in the production environment.

  2. FWIIW … On Ubuntu18.4 the solutions mentioned above of pre=installing setuptools_rust, updating pip, or exporting CRYPTOGRAPHY_DONT_BUILD_RUST=1 did not work at all.

    What ended-up doing the trick is pinning the version of cryptography at 3.3.2; in case it helps anyone:

    echo "cryptography==3.3.2" > /tmp/requirements.txt
    sudo pip3 install -U docker-compose -r /tmp/requirements.txt
    rm /tmp/requirements.txt
  3. Upgrading pip3 helps as well:

    pip3 install "pip>=20"

    You may want to use user’s home or venv based installation though so that the original pip provided by the deb package is not replaced