Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saltyfireball/e7f1ab561bcbf94e00b9a3ac270ea14a to your computer and use it in GitHub Desktop.
Save saltyfireball/e7f1ab561bcbf94e00b9a3ac270ea14a to your computer and use it in GitHub Desktop.
Install pgAdmin4 v3.6 on Ubuntu 18.04 w/python 3.6 using DESKTOP mode

Install pgAdmin4 v3.6 on Ubuntu 18.04 w/python 3.6 using DESKTOP mode

This will also work with pyenv, but if its confusing I can make different notes.

Important!

Following these exact steps will not require a username and password to access pgadmin4, since its running in "desktop" mode.

1. Create virtualenv in dir ~/py3-venv-pgadmin (different if using pyenv)

virtualenv --system-site-packages --no-setuptools --python=python3.6 ~/py3-venv-pgadmin

2. Activate virtualenv (different if using pyenv)

cd ~/py3-venv-pgadmin/bin
source activate

3. Install pgAdmin4

Make sure to use the right pip, especially if using pyenv with shims.

Reference your download location or use the url if possible

If you need to download the whl

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

Install from local file

~/py3-venv-pgadmin/bin/pip3.6 install pgadmin4-3.6-py2.py3-none-any.whl

Install from url

~/py3-venv-pgadmin/bin/pip3.6 install  https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v3.6/pip/pgadmin4-3.6-py2.py3-none-any.whl
cd ~/py3-venv-pgadmin/lib/python3.6/site-packages/pgadmin4
touch config_local.py
vi config_local.py

config_local.py

import os
SERVER_MODE = False
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')

5. Run setup (different with pyenv)

~/py3-venv-pgadmin/bin/python ~/py3-venv-pgadmin/lib/python3.6/site-packages/pgadmin4/setup.py

6. Run pgAdmin4 (different with pyenv)

~/py3-venv-pgadmin/bin/python ~/py3-venv-pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py

7. pgadmin4 run script ~/py3-venv-pgadmin/pgadmin4.sh

#!/usr/bin/env bash
cd ~/py3-venv-pgadmin/bin
source activate
~/py3-venv-pgadmin/bin/python ~/py3-venv-pgadmin/lib/python3.5/site-packages/pgadmin4/pgAdmin4.py

8. Create alias for bash/zsh shell

  • ~/.zshrc - for zsh
  • ~/.bashrc - for bash
alias pgadmin4='~/py3-venv-pgadmin/pgadmin4.sh'

9. reload shell

  • zsh
source ~/.zshrc
  • bash
source ~/.bashrc

10. now you can run pgadmin4 with the alias

pgadmin4
@Nitish3793
Copy link

source ~/.zshrc
is giving error : bash: source: /home/nitish/: is a directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment