pgAdmin is open source administration platform for PostgreSQL. It provides number of functionalities to perform on the database from a browser. This post will describe step by step guide for installing pgAdmin4 on Ubuntu 16.04 and Ubuntu 17.04.
- Python 2.7
Update ubuntu environment
sudo apt-get update
Install python 2.7 pip and Virtualenv by running this command
sudo apt-get install python2.7-dev virtualenv python-pip libpq-dev
create a directory for your python environment
Let’s create directory for pgAdmin4 at your /home/ubuntu in a apps folder
mkdir -p ~/apps/pgadmin4
Go to apps directory and then make pgadmin4 directory to a virtual environment
sample output – Output like this will appear on your screen
Running virtualenv with interpreter /usr/bin/python2 New python executable in /home/q/apps/pgadmin4/bin/python2 Also creating executable in /home/q/apps/pgadmin4/bin/python Installing setuptools, pkg_resources, pip, wheel...done.
Activate your virtual environment
* After successfully activating pgadmin4 will be start appearing in bracket like this (pgadmin4)
Download Latest python wheel file
Run a wget request to download file, in my case v4.2.0 is latest in your case it may vary so please change download url as per version requirement.
After running this command something like this will appear on your screen this means download is complete
pgadmin4-2.0-py2.py3-none-any.whl 100%[==================================================================>] 59.18M 11.6MB/s in 6.0s
Install from python wheel file
Now run the python wheel file by running
pip install pgadmin4-2.0-py2.py3-none-any.whl
After successful installation, you need to run config_local.py from installation path which is a copy of config.py located at lib/python2.7/site-packages/pgadmin4/config.py
create a file config_local.py using command below
and paste following code
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
Now run this final command for running pgAdmin4 in your local ubuntu computer
you will see something like this in terminal
Starting pgAdmin 4. Please navigate to http://127.0.0.1:5050 in your browser.
Now just navigate in browser to http://localhost:5050 to see your pgAdmin4 running
Create pgAdmin4 Shortcut on Desktop for easy starting pgAdmin4
Create a shell file on your desktop like this, as it would help to restart pgAdmin4 when you will restart your Ubuntu computer
and put the following command that we have used earlier in this blog. I have added source line after suggestion from LUQMAAN ( see comments below ), since this will help to start PgAdmin after computer restart.
source ~/apps/pgadmin4/bin/activate python ~/apps/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
now make it executable by running
chmod +x ~/Desktop/pgadmin4
now you can run it from desktop too, Go to desktop by cd ~/Desktop and run
>> If you are looking to install PgAdmin4 in server mode check this blog post