Skip to content

Instantly share code, notes, and snippets.

@saltyfireball
Last active December 21, 2018 01:04
Show Gist options
  • Select an option

  • Save saltyfireball/49df7743fe8bbab2de5c95a06a99df6b to your computer and use it in GitHub Desktop.

Select an option

Save saltyfireball/49df7743fe8bbab2de5c95a06a99df6b to your computer and use it in GitHub Desktop.
Install pgAdmin4 v3.6 with pyenv on Ubuntu 18.04 DESKTOP MODE

Install pgAdmin4 v3.6 with pyenv on Ubuntu 18.04 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. Install python 3.6.5 with pyenv

pyenv install 3.6.5

2. Setup pyenv virtual env

pyenv virtualenv 3.6.5 pgadmin

3. Setup directory for pgadmin - optional

Make directory

mkdir ~/pgadmin
cd ~/pgadmin
pyenv local pgadmin

4.

Make sure to use the right virtualenv, if you didnt follow step 3

Reference your download location or use the url if possible

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

File contents:

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')

6. setup pgadmin

cd ~/pgadmin |  # incase you left the directory
python ~/.pyenv/versions/pgadmin/lib/python3.6/site-packages/pgadmin4/setup.py

7. Run pgAdmin4

make sure everthing is working.

cd ~/pgadmin |  # incase you left the directory
python ~/.pyenv/versions/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py

If you get any errors, make sure you have right pyenv virtualenv active (step #3)

7. pgadmin4 run script ~/pgadmin/pgadmin4.sh

vi ~/pgadmin/pgadmin4.sh

~/pgadmin/pgadmin4.sh content:

#!/usr/bin/env bash
cd ~/pgadmin
python ~/.pyenv/versions/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py

8. Create alias for bash/zsh shell

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

9. Set execute permissions

chmod +x ~/pgadmin/pgadmin4.sh

10. reload shell

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

11. now you can run pgadmin4 with the alias

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