Python 3.6 Package Installation Error in Docker Alpine Image

As I was trying to create an alpine image with python 3.6.7 version and also wanted to install other Python packages from requirements.txt with pip. Docker build kept running into ERROR.

effi and ssl could not build with gcc. It took me awhile to find out why it’s happening. In the beginning I thought it was an issue with pip version of python 3 because some of the issue discussion in GitHub lead me to believe it was an issue with pip. But upgrading pipsetptools and wheel didn’t help.

After a while, I have found that gcc requires libffi-dev and libressl-dev to completely build the cryptography package for python’s several extension packages. So I installed these libraries before attempting to install those third-party python packages.

Apline: 3.8 image –

apk --update add bash python3 openssl ca-certificates python3-dev build-base libressl-dev libffi-dev

Enjoy!