ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly python python

ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly


Setting cryptography to version 2.8 in requirements.txt fixed the issue.


TLDR;

Try using cryptography==3.1.1

Details:

This happened on Python 3.9.0 on Windows 10 PC.I had the following in requirements.txt

cryptography==2.8

I removed the version and kept only cryptography in requirements.txt file like below

cryptography

Saved the requirements.txt and then I ran

pip install -r requirements.txt

It installed successfully.Then I freeze the requirements.txt by running the following command

pip freeze > requirements.txt

Then the requirements.txt got updated with cryptography==3.1.1


Had also this issue. If you're using alpine, make sure that all dependencies for cryptography are installed.In my case the cargo package was missing and causing the issue.

sudo apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo

https://cryptography.io/en/latest/installation.html#building-cryptography-on-linux