I tried many ways to install pgAdmin4 on Ubuntu 16.04/18.04, every time I got different errors. Following the below instructions will help successfully install pgAdmin4 Desktop on Ubuntu.
$ sudo apt-get install virtualenv python-pip libpq-dev
$ virtualenv pgadmin4
$ cd ~/pgadmin4
$ source bin/activate
Note: this link may change in the future, if it can not download the 'whl' file, try to check the link https://ftp.postgresql.org/pub/pgadmin/pgadmin4/ and install the latest version of pgadmin.
$ wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.4/pip/pgadmin4-1.4-py2.py3-none-any.whl
$ pip install pgadmin4-1.4-py2.py3-none-any.whl -U psycopg2
"-U psycopg2" makes sure you install all dependencies and upgrade psycopg2.
single-user mode
$ echo "SERVER_MODE = False" >> ~/pgadmin4/lib/python2.7/site-packages/pgadmin4/config_local.py
$ python ~/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
It returns: .... Starting pgAdmin 4. Please navigate to http://localhost:5050 in your browser.