8

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

  • 4
    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

4 Answers4

5

Installing psycopg2-binary worked for me.

egoens
  • 73
  • 1
  • 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
4

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

Alex Ramalho
  • 406
  • 4
  • 12
0

you can try this:

pip install psycopg2-binary

if this does not help you try this:

xcode-select --install
pip install psycopg2-binary

another way is this:

brew install postgresql
pip install --no-binary :all: psycopg2
baharaz78
  • 1
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 19 '23 at 21:30