I have the same issue with my arm64 build.
When I build a Docker Container based on Python3 (Debian).
If I build for arm64 I see it will install libpq version 9
WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64) and no specific platform was requested
Python 3.10.0 (default, Nov 18 2021, 00:02:14) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> print(psycopg2.__libpq_version__)
90623
>>> print(psycopg2.extensions.libpq_version())
90623
>>>
but if I build the exact same dockerfile on a amd64 CPU i got a different version installed.
Python 3.10.0 (default, Nov 17 2021, 15:26:39) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> print(psycopg2.__libpq_version__)
130003
>>> print(psycopg2.extensions.libpq_version())
130003
I did also tried with python:3-alpine
for arm64 and get a much better result.
WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64) and no specific platform was requested
/src # python
Python 3.10.0 (default, Nov 30 2021, 00:28:27) [GCC 10.3.1 20211027] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> print(psycopg2.__libpq_version__)
140001
>>> print(psycopg2.extensions.libpq_version())
140001
>>>
So I guess the issue is the repo that Debian/Ubuntu are using.
Maybe you should open a ticket with Debian and Ubuntu to update that package for Postgresql-client for arm64.