Why psycopg2 is not able to install in a virtual environment?

Solution 1:

Solved with

sudo apt-get install libpq-dev

Solution 2:

Try

pip install psycopg2-binary

This will not require any C code compilation