Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python psycopg2 SCRAM authentication

I'm trying to run a python application that uses psycopg2-binary==2.9.1, but I'm hitting this error:

psycopg2.OperationalError: SCRAM authentication requires libpq version 10 or above

When I check the version of libpq installed, it suggests I have 12.8:

sudo dpkg -l | grep libpq
ii  libpq5:arm64                       12.8-0ubuntu0.20.04.1             arm64        PostgreSQL C client library

I searched around and saw some recommendations to switch off scram authentication, so I changed authentication to md5 in pg_hba.conf and postgresql.conf and then reloaded config (and restarted my database).

I'm still getting this problem. Does anyone know what is wrong ? Thanks in advance

like image 574
David Co Avatar asked Jun 07 '26 22:06

David Co


1 Answers

I'm using apple silicon (M1 Pro).

In my environment (python debian image on docker), the solution is to upgrade libpq and install build tools, then build psycopg2-binary from source.

ubuntu example code:

sudo apt update -y && sudo apt install -y build-essential libpq-dev
pip install psycopg2-binary --no-binary psycopg2-binary
like image 65
Jiho Lee Avatar answered Jun 09 '26 12:06

Jiho Lee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!