Can't install psycopg2 on macOS Catalina

.

I am trying to install psycopg2 in my Django project. I have run the following command:

pip install psycopg2==2.7.*

However, I am getting the following error:

psycopg/psycopgmodule.c:689:18: error: incomplete definition of type 'struct _is'

I tried the answer to the following Stack Overflow question, but the same error persists.

Try installing psycopg2-binary instead of psycopg2:

pip install psycopg2-binary==2.7.*

This should solve the issue.