Undeterminable error with pgAdmin 4

Solution 1:

A ticket about this error exists in the postgres bugtracker.
The problem is due to python3-psycopg2. The latest pgadmin4 version requires psycopg2 2.8. But if you're on Debian/Ubuntu stable, apt installed v2.7.
So we need to add the latest version with pip :

sudo pip3 install -U psycopg2

Then add the /usr/local/lib in the pgadmin PythonPath (and hope it'll be first in the path):

nano ~/.config/pgadmin/pgadmin4.conf # or with a right click on the system tray icon
# add /usr/local/lib/python3.7/dist-packages to the PythonPath.

You'll have to change this path if you're using another version of Python.
Hope this helps.

Edit (after reading Quique response):
This is not a problem if you have two versions of psycopg2 ; the v2.8 will only be accessible through /usr/local/lib.
If you try to uninstall the v2.7 debian package, you may have some issues with other packages that depends on it (QGIS for example).

Solution 2:

vidlb is spot on, I will just add a couple of details:

  1. In order to install psycopg2 2.8 using, you must first uninstall the psycopg2 debian package, which will also uninstall pgadmin4.
sudo apt-get remove --purge psycopg2
sudo pip3 install -U psycopg2
sudo apt install pgadmin4
  1. The easiest way to update the Python Path is to click with the mouse right button on the pgadmin system tray icon, and then select Configure... In the Python tab, fill the Python Path box with /usr/local/lib/python3.6/dist-packages (or the correct path for your system). Alternatively, you can edit the ~/.config/pgadmin/pgadmin4.conf to look something like
[General]
ApplicationPath=
BrowserCommand=
FixedPort=false
PortNumber=1
PythonPath=/usr/local/lib/python3.6/dist-packages

Solution 3:

Thanks a lot vidlb and Quique!

As vidlb stated above, there is a currently a bug pertaining to the psycopg2 package for pgadmin4. If any one is having trouble with this issue on Debain and Ubuntu please refer to link below on this bug. Warning you have to have an account with Redmine before veiwing the status report.

Bug#4520

Note #7 in particular has a quick fix for Debian and Ubuntu users. I also updated from stretch to buster because stretch doesn't have apt support for Python 3.7 and I didn't feel like installing the Python updates manually.

Everything works fine now, cheers!