Django 4.2 + Psycopg3 issues

I’m trying to deploy a simple Django 4.2 website with psycopg-binary. It works with psycopg2-binary but for psycopg-binary I get “django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 or psycopg module” error, which implies it wasn’t installed in my virtual environment or requirements.txt file. But it’s most definitely there. Django added support for psycopg in the 4.2 release. This feels like a Fly issue unless I’m really missing something here. Have been able to reproduce several times flipping back and forth between psycopg2 and psycopg versions.

Any else having this issue? @katia

2 Likes

Ok, sorted this out. The installation method for binary psycopg changed slightly. Need to do python -m pip install "psycopg[binary]" now. That worked. Odd.

2 Likes

More context here: Psycopg3 Binary and Django 4.2 Installation Quick Tip | LearnDjango.com

1 Like

Thanks for sharing, @wsvincent ! :slight_smile:

Do you get the following error by any chance? @wsvincent
couldn't import psycopg 'c' implementation: No module named 'psycopg_c'

Nope. Sorry I can’t help there!