Running PI with postgresql as database

Hi,

I re-installed my PI-server with ansible and want it to connect to a remove postgresql-cluster.
psycopg2 is installed but when uwsgi is started I get this error in privacyidea.log:

File "/opt/privacyidea/lib/python3.6/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 737, in dbapi
    import psycopg2
ModuleNotFoundError: No module named 'psycopg2'

but psycopg2 is installed:

root@PISRV:/# apt list |grep psycopg

python-psycopg2/bionic,now 2.7.4-1 amd64 [installed]
python-psycopg2-dbg/bionic 2.7.4-1 amd64
python-psycopg2-doc/bionic,bionic 2.7.4-1 all
python3-psycopg2/bionic,now 2.7.4-1 amd64 [installed]
python3-psycopg2-dbg/bionic 2.7.4-1 amd64

pip also knows it:

root@PISRV:/# pip freeze |grep psycopg2

psycopg2==2.7.4
psycopg2-binary==2.8.5

How or where is psycopg2 installed right??

Thanks in advance
Andreas

Looks like you are running a virtualenv?

nope, I installed PI with the Ubuntu-Packages

The Ubuntu packages ship a virtualenv. So you need to install psycopg2 within the virtualenv at /opt/privacyidea

source /opt/privacyidea/bin/activate
pip install psycopg2

Cornelius, you are the best!!
Thank you very much!!!