Ok first I tried the force reinstall, that changed nothing.
(venv) mailman@mail:~> pip install --force-reinstall psycopg2-binary\<2.9 Collecting psycopg2-binary<2.9 Using cached psycopg2_binary-2.8.6-cp311-cp311-linux_x86_64.whl Installing collected packages: psycopg2-binary Attempting uninstall: psycopg2-binary Found existing installation: psycopg2-binary 2.8.6 Uninstalling psycopg2-binary-2.8.6: Successfully uninstalled psycopg2-binary-2.8.6 Successfully installed psycopg2-binary-2.8.6 (venv) mailman@mail:~> python -c 'import psycopg2' Traceback (most recent call last): File "<string>", line 1, in <module> File "/opt/mailman/venv/lib64/python3.11/site-packages/psycopg2/__init__.py", line 51, in <module> from psycopg2._psycopg import ( # noqa SystemError: initialization of _psycopg raised unreported exception
Here is what is in the file that is failing, If I read this right I need to check every single sub import.
50 51 from psycopg2._psycopg import ( # noqa 52 BINARY, NUMBER, STRING, DATETIME, ROWID, 53 54 Binary, Date, Time, Timestamp, 55 DateFromTicks, TimeFromTicks, TimestampFromTicks, 56 57 Error, Warning, DataError, DatabaseError, ProgrammingError, IntegrityError, 58 InterfaceError, InternalError, NotSupportedError, OperationalError, 59 60 _connect, apilevel, threadsafety, paramstyle, 61 __version__, __libpq_version__, 62 ) 63
For grins I searched for the psycopq2 package and this may tell is something both of the 'global' pythons seem to have later versions
/opt/mailman/venv/lib/python3.11/site-packages/psycopg2 /opt/mailman/venv/lib/python3.11/site-packages/psycopg2-2.8.6.dist-info /opt/mailman.save/venv/lib/python3.8/site-packages/psycopg2 /opt/mailman.save/venv/lib/python3.8/site-packages/psycopg2_binary-2.8.6.dist-info /usr/lib64/python3.11/site-packages/psycopg2 /usr/lib64/python3.11/site-packages/psycopg2-2.9.7.dist-info /usr/local/lib64/python3.8/site-packages/psycopg2 /usr/local/lib64/python3.8/site-packages/psycopg2_binary-2.9.8.dist-info
So I went out to root root and removed the psycopq2 and binary based on the above, I also checked the python versions. This is root:
mail:/etc # python -V Python 2.7.18 mail:/etc # python3 -V Python 3.11.5 mail:/etc # pip -V pip 23.2.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8) mail:/etc # pip3 -V pip 23.2.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8) mail:/etc # pip list | grep psycopg2 << No result >>
This is mailman (venv) mailman@mail:~> python -V Python 3.11.5 (venv) mailman@mail:~> pip -V pip 23.2.1 from /opt/mailman/venv/lib64/python3.11/site-packages/pip (python 3.11) (venv) mailman@mail:~> pip list | grep psycopg2 psycopg2 2.8.6 psycopg2-binary 2.8.6
So it seems to me that wiping out the venv multiple times and recreating it produces the same result.
One last possible source of information, here are the installed postgresql packages:
S | Name | Summary | Type ---+----------------------------+-------------------------------------------------------------------------+-------- i+ | postgresql | Basic Clients and Utilities for PostgreSQL | package i+ | postgresql-contrib | Contributed Extensions and Additions to PostgreSQL | package i | postgresql-devel | PostgreSQL development header files and libraries | package i | postgresql-llvmjit | Just-in-time compilation support for PostgreSQL | package i | postgresql-llvmjit-devel | Helper package to pull all dependencies to build with llvm support | package i+ | postgresql-plperl | The PL/Tcl, PL/Perl, and PL/Python procedural languages for PostgreSQL | package i+ | postgresql-plpython | The PL/Python Procedural Languages for PostgreSQL | package i+ | postgresql-server | The Programs Needed to Create and Run a PostgreSQL Server | package i+ | postgresql-server-devel | PostgreSQL server development header files and utilities | package i | postgresql13 | Basic Clients and Utilities for PostgreSQL | package i | postgresql13-contrib | Contributed Extensions and Additions to PostgreSQL | package i | postgresql13-devel | PostgreSQL client development header files and libraries | package i | postgresql13-llvmjit | Just-in-time compilation support for PostgreSQL | package i | postgresql13-llvmjit-devel | PostgreSQL development files for extensions with LLVM support | package i | postgresql13-plperl | The PL/Tcl, PL/Perl, and PL/Python procedural languages for PostgreSQL | package i | postgresql13-plpython | The PL/Python Procedural Languages for PostgreSQL | package i | postgresql13-server | The Programs Needed to Create and Run a PostgreSQL Server | package i | postgresql13-server-devel | PostgreSQL server development header files and utilities | package i | postgresql16 | Basic Clients and Utilities for PostgreSQL | package i | postgresql16-contrib | Contributed Extensions and Additions to PostgreSQL | package i | postgresql16-llvmjit | Just-in-time compilation support for PostgreSQL | package i | postgresql16-plperl | The PL/Tcl, PL/Perl, and PL/Python procedural languages for PostgreSQL | package i | postgresql16-plpython | The PL/Python Procedural Languages for PostgreSQL | package i | postgresql16-server | The Programs Needed to Create and Run a PostgreSQL Server | package