13

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

https://www.pgadmin.org/ https://www.postgresql.org/ftp/pgadmin3/pgadmin4/

Victor
  • 9,313

3 Answers3

19

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
ffflabs
  • 301
  • 2
  • 6
10

Those are the instructions to install in Server mode. For Desktop mode, see How to install pgAdmin 4 in desktop mode on Ubuntu 16.04.

For pgAdmin 4 v1.4 on Ubuntu 16.04, according to the download page:

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

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

cd
virtualenv pgadmin4
cd pgadmin4
source bin/activate

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

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

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

# Minimum configuration for config_local.py
CSRF_SESSION_KEY = 'Change this now'
SECRET_KEY = 'Change this now'
SECURITY_PASSWORD_SALT = 'Change this now'

Run

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

Access at http://localhost:5050

Victor
  • 9,313
  • 2
    A note. If you need to start server later (e.g. schedule it to run at boot) final "Run" step won't work unless you execute "source bin/activate" every time prior to starting the server. – oᴉɹǝɥɔ Oct 19 '16 at 14:52
  • I am able not able to access using ip like : http://192.168.0.12:5050. It's only working on http://localhost:5050 – Thirumal Apr 14 '17 at 05:04
4

One way to install pgadmin4 is to download its Python wheel at https://www.postgresql.org/ftp/pgadmin3/pgadmin4/v1.0-beta1/pip/ and then use pip to install it:

wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.0-beta1/pip/pgadmin4-1.0_beta1-py2-none-any.whl
pip install pgadmin4-1.0_beta1-py2-none-any.whl

Note that the wheel only works for Python 2. If you get an error message that says "Error: pg_config executable not found.", install pg_config by running sudo apt-get install libpq-dev according to https://stackoverflow.com/q/11618898/486919.

According to https://www.pgadmin.org/download/pip4.php, to run pgadmin4, do the following:

Once installed, you will need to create a config_local.py file in the same directory as config.py. On a machine with a virtual environment created at ~/pgadmin4, this is ~/pgadmin4/lib/python2.7/site-packages/pgadmin4. Ensure you set values for the SECRET_KEY, SECURITY_PASSWORD_SALT and CSRF_SESSION_KEY settings at bare minimum - see config.py for more information and other settings that can be customised. In order to reference other variables from config.py, you may need to include from config import * at the top of config_local.py.

pgAdmin can now be run with a command like python ~/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py. Finally, point your browser to http://127.0.0.1:5050.

edwinksl
  • 23,789
  • While the pip install finished successfully, I'm not sure where to do from here. The binary for pgadmin4 does not get built/installed. Can someone provide further instructions? – Jonathan Dunlap Jul 27 '16 at 00:59
  • 1
    That is beyond the scope of the question and this answer. Consider asking a new question if no duplicates exist. – edwinksl Jul 27 '16 at 01:36
  • 4
    Why is it beyond the scope? The question is "how to install pgadmin4" and the answer does not actually install it. – Jonathan Dunlap Jul 28 '16 at 03:40
  • @JonathanDunlap If the pip installation is successful, then pgAdmin 4 is indeed installed and you can run pgAdmin 4. Read https://www.pgadmin.org/download/pip4.php to see how to do it. I just tried it out and it works for me. Therefore, what you are really asking is "how to run pgAdmin 4", which is a different question from OP's question asking "how to install it". I could have also added instructions on how to run it, but that would just be me going beyond what OP asked for and therefore strictly optional as far as I am concerned. – edwinksl Jul 28 '16 at 04:29
  • 3
    My god that is pedantic. The last step of installing it is running it. I came here, and I have the same question. Is the purpose of this site to help people or to be pedantic? – light24bulbs Oct 13 '16 at 16:38
  • Just came here with the same question and saw this answer. I've created and account here just to downvote this guy, jesus. – Vinicius Tavares Oct 16 '16 at 18:14
  • Woah, calm down people. Surely we can agree to disagree on how to interpret what "install" means. Installing and running are still distinct in my opinion, but since you both wanted to also know how to run pgadmin4, I will include instructions on how to do so. – edwinksl Oct 16 '16 at 18:24