OSError: [Errno 13] Permission denied: '/var/lib/pgadmin'

Michael picture Michael · Oct 12, 2017 · Viewed 20.4k times · Source

Ubuntu 16.04.3

I'd like to install pgAdmin:

I hvae created a virtualenv with python 2.

Then install pgAdmin 4 v2.0:

pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.0/pip/pgadmin4-2.0-py2.py3-none-any.whl

It's time to run pgAdmin:

(pgadmin4) michael@michael-desktop:~/PycharmProjects/venv$ python pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
Traceback (most recent call last):
  File "pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py", line 55, in <module>
    exec(open(file_quote(setupfile), 'r').read())
  File "<string>", line 46, in <module>
  File "/home/michael/PycharmProjects/venv/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 23, in create_app_data_directory
    _create_directory_if_not_exists(os.path.dirname(config.SQLITE_PATH))
  File "/home/michael/PycharmProjects/venv/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 15, in _create_directory_if_not_exists
    os.mkdir(_path)
OSError: [Errno 13] Permission denied: '/var/lib/pgadmin'

Could you give me a kick here?

Answer

Murtuza Z picture Murtuza Z · Oct 13, 2017

If you do not want to change the permission of anything, you can always override default paths in pgAdmin4.

Create a file named config_local.py (if not already present) at your installation location ../pgadmin4/web/

File location in my case: /usr/local/lib/python2.7/dist-packages/pgadmin4/config_local.py

and add following code in your 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')

Restart pgAdmin4 and check.