How to install PgAdmin4 on Ubuntu 16.04
To install PgAdmin4 on Ubuntu 16.04
PgAdmin is a popular open source management and development tool which is released under PostgreSQL/Artistic license. Different types of database operations can be done easily from the browser by using this software. This software can be used on most popular operating systems. Currently, pgAdmin 4 is released and it is developed using Python and JQuery. Many improvements are done in pgAdmin 4 compared to pgAdmin 3. Anyone can download the source or binary file of this software based on a particular operating system for installation. It is so simple to install PgAdmin4 on Ubuntu 16.04, and this article covers the ground on the same process.
Installing PgAdmin4
Before you begin the process, you need to update your system, and for that, make use of the following command.
user@linuxhelp:~$ sudo apt-get update
Hit:1 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu xenial InRelease
.
.
Fetched 1,565 kB in 5s (300 kB/s)
Reading package lists... Done
And then, you need to Install the required packages - are python, pip and virtualenv. So, run the following command to install them in your system.
user@linuxhelp:~$ sudo apt-get install build-essential libssl-dev libffi-dev libgmp3-dev virtualenv python-pip libpq-dev python-dev
Reading package lists... Done
Building dependency tree
.
.
Processing triggers for libc-bin (2.23-0ubuntu9) ...
bingwallpaper
After it is done, you need to create a virtual environment by making use of the following command.
user@linuxhelp:~$ mkdir pgAdmin4
user@linuxhelp:~$ cd pgAdmin4/
user@linuxhelp:~/pgAdmin4$ virtualenv pgAdmin4
Running virtualenv with interpreter /usr/bin/python2
.
.
Installing setuptools, pkg_resources, pip, wheel...done.
And then, activate the virtual environment by executing the following command.
user@linuxhelp:~/pgAdmin4$ cd pgAdmin4/
user@linuxhelp:~/pgAdmin4/pgAdmin4$ source bin/activate
Once all of these is done, you shall download the PgAdmin4 by using the wget command followed by its download link in as follows.
user@linuxhelp:~/pgAdmin4/pgAdmin4$ wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.1/pip/pgadmin4-2.1-py2.py3-none-any.whl
.
.
pgadmin4-2.1-py2.py3-none-any.whl 100%[==========================================================> ] 66.22M 958KB/s in 66s
You shall now install your PgAdmin4 application by running the following command.
user@linuxhelp:~/pgAdmin4/pgAdmin4$ pip install pgadmin4-2.1-py2.py3-none-any.whl
Processing ./pgadmin4-2.1-py2.py3-none-any.whl
Collecting pytz==2014.10 (from pgadmin4==2.1)
.
.
python-editor-1.0.3 python-mimeparse-1.5.1 pytz-2014.10 simplejson-3.6.5 six-1.11.0 speaklater-1.3 sqlparse-0.1.19 testtools-2.3.0 traceback2-1.4.0 unittest2-1.1.0
And after the download, you need to configure and run PgAdmin4 by making use of the following command.
user@linuxhelp:~$ nano lib/python2.7/site-packages/pgadmin4/config_local.py
Add the following content in config_local.py.
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
After the installation, you can run the following commands to run pgAdmin
user@linuxhelp:~$ python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
user@linuxhelp:~/pgAdmin4/pgAdmin4$ pip install flask-htmlmin
Requirement already satisfied: flask-htmlmin in ./lib/python2.7/site-packages
.
.
Requirement already satisfied: itsdangerous> =0.21 in ./lib/python2.7/site-packages (from Flask-> flask-htmlmin)
Requirement already satisfied: markupsafe in ./lib/python2.7/site-packages (from Jinja2> =2.4-> Flask-> flask-htmlmin
And check and see if PgAdmin4 runs successfully by running the following command.
user@linuxhelp:~/pgAdmin4/pgAdmin4$ python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
pgAdmin 4 - Application Initialisation
======================================
Starting pgAdmin 4. Please navigate to http://127.0.0.1:5050 in your browser
You can open your newly installed pgAdmin4 in your browser.
With this the installation of PgAdmin4 on Ubuntu-16.04 comes to an end.
In desktop mode, the process varies depending on the platform:
Linux: Start the desktop runtime from the command line, e.g. /usr/local/pgadmin4/bin/pgadmin4, adjusting the path as necessary.
MacOS: Start the desktop runtime from the command line, e.g. /Applications/pgAdmin\ 4.app/Contents/MacOS/pgAdmin4, adjusting the path as necessary.
Windows: Console logs can be written to a file from the command line on Windows, e.g. "C:\Program Files\pgAdmin 4\v2\runtime\pgAdmin4.exe" > %TEMP%\pgadmin-console.log will write a log to %TEMP%\pgadmin-console.log.