Ubuntu – How to install pgAdmin 4 in server mode on Ubuntu 16.04


How to install pgAdmin 4 on Ubuntu 16.04 ? Lack of information on homepage.


Best Answer

These are the steps I followed to make it run:

1) I didn't have virtualenvwrapper installed, so I (duh!) installed it

sudo pip install virtualenvwrapper

2) Standing on my home folder, I made a pgadmin virtual environment, which creates a pgadmin folder, inside of which I tell it to activate itself

cd ~
virtualenv pgadmin
cd pgadmin
source bin/activate

3) Inside my virtual environment, I make sure to have required dependencies so I'd be able to build wheel for pycrypto and psycopg2

sudo apt-get install build-essential libssl-dev libffi-dev python-dev libgmp3-dev
sudo pip install cryptography pyopenssl ndg-httpsclient pyasn1 

4) Having the required deps, now I can download and pip install the latest pgadmin4 release

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

5) pgAdmin4 is installed in my virtualenv, now I need to create a config_local.py in the same folder it was installed, and I will use config.pyas the base. So, let's find that one first:

find . -wholename "*pgadmin4/config.py"

6) It tells me it's in ./lib/python2.7/site-packages/pgadmin4/config.py so now I can copy it and run pgAdmin4:

cp ./lib/python2.7/site-packages/pgadmin4/config.py ./lib/python2.7/site-packages/pgadmin4/config_local.py
python  ./lib/python2.7/site-packages/pgadmin4/pgAdmin4.py

The webapp is now running at http://localhost:5050

### EDIT ###

To avoid updating this thread each time a new version of pgAdmin4 is released, i made a pgadmin4_installer repo at GitHub with:

  • a detailed README.md
  • an AptFile with system packages to install
  • Makefile tasks to create virtualenvs specific to python2 or python3, according to your preference
  • Makefile tasks to install requirements (python2 or python3)
  • Instructions to run as an uwsgi script
  • Instructions to create an uwsgi service with autostart on reboots
Related Question