PgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database. Installing the last version under CentOS 7 can be a bit tricky, here it is one way how to do it.

Download the Python wheel for the last pgAdmin release listed on the following page : https://www.pgadmin.org/download/pgadmin-4-python-wheel/.

cd ~/Downloads
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.3/pip/pgadmin4-4.3-py2.py3-none-any.whl

The pgAdmin 4 team advices to use a virtual environment therefore create one dedicated to pgAdmin.

conda create -n pgadmin4 python=3.6

Activate this new environment.

source activate pgadmin4

Install the Python wheel you just download.

pip install pgadmin4-4.3-py2.py3-none-any.whl

Check the pgAdmin4 installation location.

sudo find / -name pgAdmin4.py

It should return something like:

/home/username/anaconda3/envs/pgadmin4/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py

Edit a config_local.py in the same directory.

vi /home/username/anaconda3/envs/pgadmin4/lib/python3.5/site-packages/pgadmin4/config_local.py

Insert (i) in it the following content:

import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions') 
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
SERVER_MODE = False

Save and close this configuration file (:wq).

Run pgAdmin 4.

python $(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib() + '/pgadmin4/pgAdmin4.py')")

Open the given to address (http://127.0.0.1:5050) to access the PgAdmin 4 interface.

Create a shortcut

Create a dedicated folder for your shortcuts.

mkdir ~/.shortcuts
touch ~/.shortcuts/pgadmin4
chmod +x ~/.shortcuts/pgadmin4

Edit in it a bash script for pgadmin4

vi ~/.shortcuts/pgadmin4

..with the following content:

#!/bin/bash
source activate pgadmin4
python /home/username/anaconda3/envs/pgadmin4/lib/python3.5/site-packages/pgadmin4/pgAdmin4.py

Save and close it (:wq).

Add the ~/.shortcuts directory to your ~/.bashrc file.

echo 'export PATH="/home/username/.shortcuts:$PATH"' >> ~/.bashrc

In a new terminal window, you will now be able to launch pgAdmin 4 just by typing the pgadmin4 command.