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/

1
  • ... My question is about pgAdmin 4. There is pgAdmin 3 only in this repo. Jun 18, 2016 at 14:12

3 Answers 3

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
5
  • Dead link. 404. Apr 14, 2017 at 6:57
  • how do I access it from other computer using ip. It accessible only by using localhost:5000
    – Thirumal
    May 2, 2017 at 16:55
  • 1
    @TurtlesAreCute, there, I updated the package http link
    – ffflabs
    May 3, 2017 at 11:57
  • what's the proper way of making this boot with the machine?
    – Arya
    Oct 13, 2017 at 0:03
  • after creating an conf file in /etc/init you should be able to use sudo update-rc.d uwsgi enable. That, or create an entry in root's crontab like @reboot /usr/sbin/service uwsgi start &> /dev/null
    – ffflabs
    Oct 13, 2017 at 10:41
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

2
  • 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. Oct 19, 2016 at 14:52
  • I am able not able to access using ip like : 192.168.0.12:5050. It's only working on localhost:5050
    – Thirumal
    Apr 14, 2017 at 5: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.

7
  • 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? Jul 27, 2016 at 0: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, 2016 at 1:36
  • 4
    Why is it beyond the scope? The question is "how to install pgadmin4" and the answer does not actually install it. Jul 28, 2016 at 3:40
  • @JonathanDunlap If the pip installation is successful, then pgAdmin 4 is indeed installed and you can run pgAdmin 4. Read 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, 2016 at 4: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? Oct 13, 2016 at 16:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .