7

when installing psycopg2 in my Django project

pip install psycopg2==2.7.*

I get this error :

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

I tried the answer to the following question: Is there any problem installing psycopg2 in virtualenv on MacOS catalina with PostgreSQL 12.1 installed? but I still get the same error

  • 3
    Try installing `psycopg2-binary` instead – Iain Shelvington Jan 04 '20 at 23:15
  • 1
    Yes I do it, and it ok, but i can't install my second library django-heroku this library look for psycopg2 – Adama OUEDRAOGO Jan 04 '20 at 23:28
  • 1
    Try `pip install django-heroku --no-dependencies` and then install the other dependencies yourself. The other dependencies are "dj-database-url>=0.5.0" and "whitenoise" – Iain Shelvington Jan 04 '20 at 23:38
  • Are you using virtual environments? Did the suggestion by @IainShelvington work? – AMC Jan 05 '20 at 03:32
  • yes I create my project with pycharm IDE, by default pycharm create a virtual environments with project interpreter, in my case this project interpreter is python 3.7 and pip 10.0.1 – Adama OUEDRAOGO Jan 05 '20 at 11:48
  • I try pip install django-heroku --no-dependencies , and when I try pip install dj-database-url>=0.5.0 , I get this error : "django-heroku 0.3.1 requires psycopg2, which is not installed." – Adama OUEDRAOGO Jan 05 '20 at 11:59

3 Answers3

4

Installing psycopg2-binary worked for me.

egoens
  • 63
  • 4
  • Note the caveat about psycopg2-binary: "The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources." https://github.com/psycopg/psycopg2 – Adam Parkin Oct 14 '20 at 16:07
3

If you are using Python 3.8.x then the support for the same was added in psycopg2 2.8.x. I faced the same problem but worked out fine once I switched to python 3.7.x

0

Installing PostgreSQL fixed it for me, but the error was not exactly the same. Anyways, give it a try:

brew install postgresql

Cheers