Installing PyCrypto on Ubuntu - fatal error on build

Solution 1:

You need to install the Python development files. I believe this will do it:

sudo apt-get install python-dev

Solution 2:

On Ubuntu, I needed some other packages for it to succeed:

apt-get install autoconf g++ python2.7-dev
pip install pycrypto

Solution 3:

On Ubuntu and if you use Python 3.x you will need:

sudo apt-get install gcc python3-dev

you probably already have gcc but just in case if you are trying this command from Dockerfile with base image python:3.6.4-slim-jessie then you will also need gcc.

Solution 4:

August 2021

For python 3.8 users run

sudo apt-get install python3.8-dev

and try to install pycrypto again

pip install pycrypto