Postgresql - Error during connection setup: No module named 'psycopg2'

I use Hassbian on rpi2 HA 0.79.
I would like to try postgresql, because my mysql querys very slow.
My postgresql db server is on other ubuntu server. I configed it, I can connect to it.
I made on Hassbian as in https://www.home-assistant.io/components/recorder/.
But I get: ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: No module named ‘psycopg2’ error code.
What I missed?

Thank you

It looks like HA doesn’t add this module to the virtual environment. You can check by listing the packages

$ sudo systemctl stop [email protected]
$ sudo -u homeassistant -H -s
$ source /srv/homeassistant/bin/activate
$ pip3 list 

If it isn’t there, you can add the latest version manually. Within the virtual environment do

$ pip3 install psycopg2

which should work if the latest version is the one needed by HA. If it is incompatible, you will have to go and search the HA code to find out the correct version.

If the package is in the list already, something else is wrong and you need more help than I can give :thinking:

2 Likes

Thank you very much :slight_smile:
It works.

1 Like