How to install pgAdmin 4 in desktop mode? The documentation only details server mode.

  • The docker version sure was a lot easier and faster way of installing PGAdmin4. I spent a lot of time to do it the old way that was in the readme file. The way to access it then is in a browser window, point it to 0.0.0.0:5050 and it comes up real good. It loads quite fast BUT when I try to create a server with it it keeps saying that Postgresql is NOT running, however in PGAdmin3 Postgresql is running fine. Have read many comments saying what a poor product it is so use at your own risk!!! – Gerald Brown May 15 '17 at 12:54
  • 2
    Only pgadmin3 is available on apt (ubuntu 16.04). Any idea how to open a request to Canonical to include pgadmin4 in apt packages? What's the process of requesting an "app" to be included in a package manager? – AlikElzin-kilaka Dec 26 '17 at 8:47
  • @AlikElzin-kilaka - check my answer below for the apt approach. – Muhamed Huseinbašić May 30 at 13:31
up vote 132 down vote accepted

For pgAdmin 4 v3.6 on Ubuntu, according to the download page:

Install dependencies, create a virtual environment, download, install & configure

Using Python2.x

sudo apt-get install virtualenv python-pip libpq-dev python-dev

cd
virtualenv pgadmin4
cd pgadmin4
source bin/activate

pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v3.6/pip/pgadmin4-3.6-py2.py3-none-any.whl

Using Python3.6 (Preferred to avoid encoding related issues)

sudo apt-get install virtualenv python3-pip libpq-dev python3-dev

cd
virtualenv -p python3 pgadmin4
cd pgadmin4
source bin/activate

pip3 install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v3.6/pip/pgadmin4-3.6-py2.py3-none-any.whl

Configure

Override default paths and set it to single-user mode in the local configuration file:

nano lib/python2.7/site-packages/pgadmin4/config_local.py

For Python3.x:

nano lib/python3.6/site-packages/pgadmin4/config_local.py

Write:

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

Run

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

For Python3.x:

python3 lib/python3.6/site-packages/pgadmin4/pgAdmin4.py

Access

Access at http://localhost:5050

Exit

Exit with Ctrl-C

Run again

cd ~/pgadmin4
source bin/activate
python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py

For Python3.6

#!/bin/bash
cd ~/pgadmin4
source bin/activate
python3 lib/python3.6/site-packages/pgadmin4/pgAdmin4.py

Make a shortcut

touch ~/pgadmin4/pgadmin4
chmod +x ~/pgadmin4/pgadmin4
nano ~/pgadmin4/pgadmin4

Write:

#!/bin/bash
cd ~/pgadmin4
source bin/activate
python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py

For Python3.6

#!/bin/bash
cd ~/pgadmin4
source bin/activate
python3 lib/python3.6/site-packages/pgadmin4/pgAdmin4.py

Now you can just run it with a simpler command:

~/pgadmin4/pgadmin4

Python3 users

Replace [x] in Python3.6 with your respective version.

Conflict with pgAdmin 3 configuration

pgAdmin 4 will not start in the environment where pgAdmin 3 was previously installed and used because of incompatible configuration in the .pgadmin directory. The simplest solution is to either clear that directory or tweak config_local.py to point to a clean new .pgadmin4 directory.

  • 7
    Ok, following Victor's instructions and modifying for Python 3, I have pgadmin4 up and running. However, people should be aware that there are a slew of additional dependencies with this product, so you might want to take seriously the suggestion to put this in its own virtualenv, instead of an existing one as I did. My sqlparse, SQLAlchemy, six, and jinja2 were all updated to new versions. I don't think that will be a problem for me but I was not expecting this so I thought people should know in case it would affect them. – Malik A. Rumi Nov 2 '16 at 20:20
  • 2
    @Dave I'd like to take credit for an advanced and highly sophisticated breakthrough, but all I did was swap out python2.7 for python3.5 in the setup and pgAdmin4 paths. :-) Create the configuration database python lib/python3.5/site-packages/pgadmin4/setup.py Run python lib/python3.5/site-packages/pgadmin4/pgAdmin4.py – Malik A. Rumi Dec 20 '16 at 5:21
  • 4
    I'd like to add that so I can quickly run it, I added this to my ~/.bashrc : alias pgadmin="source ~/pgadmin4/bin/activate && python ~/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py" That way I can just type pgadmin and it launches, like it SHOULD out of the box. You listening pgadmin? – light24bulbs Jun 13 '17 at 21:32
  • 1
    Here is the correct link for FTP v2.1: ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.1/pip/… – Aïssa Ghouti Jan 22 at 12:42
  • 1
    Could the hard linking to python3.6 dependency in the python3 lib/python3.6/site-packages/pgadmin4/pgAdmin4.py be removed/replaced? That way the answer would be more future proof. – paul23 Sep 4 at 18:22

Other option is to use docker and a docker image provided by thaJeztah - https://github.com/thaJeztah/pgadmin4-docker

$ docker run --rm -p 5050:5050 thajeztah/pgadmin4

Then to access a PostgreSQL DB instance from within pgadmin4 you should use the IP of the host instead of localhost and 127.0.0.1 since Docker will map those to the container itself.

The IP of a dockerised DB instance could be found with 2 steps:

  • find the container ID of your db with:

    docker ps

  • inspect the container_name to find its ip with:

    docker inspect <ID from previous step>

you are looking for something like "IPAddress": "172.18.0.3"

  • 1
    How can you make it see a dockerized postgres? localhost/127.0.0.1/container id did not work for me. – ampofila Apr 18 '17 at 12:04
  • 1
    Can we set the IP static i.e. we don't have to update our application to point to new docker container IP every time we restart it – Nam G VU Sep 16 '17 at 4:45
  • Yea, man. You saved the day. – Mazhar Ahmed Oct 19 '17 at 12:34
  • Nice! works like a charm – Wouter Dec 6 '17 at 16:18
  • Nice, added a chromium application shortcut, and it's almost like having the actual application back- – chrismarx Jan 22 at 15:26

I am not sure whether I am missing something (let me know if I do), but this seems much more simple:

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add 
sudo apt update
sudo apt install pgadmin4

I have tested this on 16.04.

source for the above approach

  • 1
    This worked great on my laptop with 16.04. Even with pgAdmin 3 installed. – THelper Jun 27 at 7:29
  • 2
    Works great on 18.04! – divided Jun 29 at 13:41
  • 1
    Works fine! But I think it's not necessary to use 'sudo apt upgrade' because you can broke something) – Max Gabderakhmanov Jul 31 at 19:11
  • 1
    You're completely right, upgrade definitely has nothing to do with this installation. I wanted to remove that line before, but forgot about it. Just updated my answer, thanks! :D – Muhamed Huseinbašić Jul 31 at 19:13
  • 1
    It looks like the ultimate solution, at least for Ubuntu +16.xx. Thanks ! – Louisb Nov 19 at 10:47

protected by Community Oct 6 '17 at 23:18

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.