PgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL database.
PgAdmin is the leading graphical Open Source management, development and administration tool for PostgreSQL.
In this tutorial, we are going to show you How to install PgAdmin 4 in Desktop Mode on Ubuntu 16.04 LTS.
If you didn’t yet install PostgreSQL take a look the below links :
- How to Install PostgreSQL on Ubuntu 16.04 LTS
- How To Install PostgreSQL 9.6 on CentOS 7 / RHEL 7
- How To Change PostgreSQL Data Directory Location on Ubuntu 16.04
- How To Enable Network Remote Access To PostgreSQL Database Server
- How to install PgAdmin 4 in Server mode on Ubuntu 16.04 LTS
- How to install pgAdmin 4 in Server mode as web application on CentOS 7 / RHEL 7
Step 1. Installation Packages
# sudo apt-get install build-essential libssl-dev libffi-dev libgmp3-dev virtualenv python-pip libpq-dev python-dev
Step 2. Create the virtual environment
# cd /opt/ # mkdir enviromentpy # cd enviromentpy/ # virtualenv pgadmin4 # cd pgadmin4 # source bin/activate
Step 3. Download and install PGAdmin 4
# wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.3/pip/pgadmin4-1.3-py2.py3-none-any.whl # pip install pgadmin4-1.3-py2.py3-none-any.whl
Step 4. Create the local configuration file for PGAdmin 4
# cd lib/python2.7/site-packages/pgadmin4 # touch config_local.py
– Edit config_local.py and add any desired configuration options (use the config.py file as a reference – any settings duplicated in config_local.py will override those in config.py). To configure PGAdmin 4 to run in single-user mode add the following line:
# echo "SERVER_MODE = False" >> lib/python2.7/site-packages/pgadmin4/config_local.py
Step 4. Run PGAdmin 4
# python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py . Enter the email address and password to use for the initial pgAdmin user account: Email address: [email protected]
– you will prompt it to add an email address and a password to access PGAdmin 4
Now Access at http://localhost:5050
and connect your PostgreSQL Server
49 comments
How to access it using static IP, it’s working on only localhost:5050
Hi Thirumal,
You can load it as service and than you can use Apache or Nginx as proxy to access to pgadmin .It’s a bit easy 😉.
i have a problem to create server,
Unable to connect to server:
could not connect to server: Connection refused
Is the server running on host “192.168.1.2” and accepting
TCP/IP connections on port 5432?
please help me to fix a problem….
Hi, you have to make sure that your postgresql server is accepting remote connection . Take a look to our article describes HOW TO ENABLE NETWORK REMOTE ACCESS TO POSTGRESQL DATABASE SERVER http://yallalabs.com/linux/how-to-enable-network-remote-access-to-postgresql-database-server/
I’m a beginner in ubuntu step 1 to 3, When i typed “cd lib/python2.7/site-packages/pgadmin4” it says “No such file or directory” .
When i try to check my directory /lib there is no python2.7 there, what i should i do?
Correction: i’m already at “/lib/python2.7/site-packages” directory but i dont have the pgadmin4? what can possibly the problem here?
HI Jeff,
we have created a directory called ” enviromentpy ” and after that we used virtualenv to create the virtual enviroment “” pgadmin4 “”
make sure that u are under the directory “” enviromentpy “”
sorry but me too when i typed “cd /lib/python2.7/site-packages/pgadmin4” it says “No such file or directory” .
Make sure that u are in the right path using the following command ” cd lib/python2.7/site-packages/pgadmin4 “
What would be full path? Im in the same error… Thks
The full path is ” /enviromentpy/pgadmin4/lib/python2.7/site-packages/pgadmin4 ” if you are in pgadmin4 directory just use the following command ” cd lib/python2.7/site-packages/pgadmin4″ like in the step number 4. Tell us if you still have problems.
I think you need run command as root, ‘sudo su-`
Obviously, we used a super user to run all commands
Hi Lotfi, I followed your tutorial but I see only python3.5 in the lib folder. When I cd into site-packages, there is no pgadmin4 folder.
Hi Ondra, make sure to create the virtual Enviroment and activate it correctly and after that use the pip command to deploy the PgAdmin 4.
Hi I am at “/enviromentpy/pgadmin4/lib/python2.7/site-packages/” directory. But there is no pgadmin4 folder. If I create a folder named “pgadmin4” is it enough? Or what can I do?
Hi Fatih,
You should not create the PgAdmin4″ should be autocreated after executing the following command ” pip install pgadmin4-1.3-py2.py3-none-any.whl”
Make sure that you run the command correctly .
pgadmin4 no such directory
You have to run this command
# pip install pgadmin4-1.3-py2.py3-none-any.whl
Guys, to fix this problem you need to be root, before start the tutorial use sudo -i to log as root, this solved to me
Thx
Thank you very much. You helped me a lot to install on ubuntu 15.10/pg 9.6.
But in ubuntu 16.04/pg 9.5, python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py doesn’t ask the username/password. What to do ?
Thanks,
Michel Depiesse Consulting
Antwerp
Hi MICHEL DEPIESSE,
You are welcome anytime, it’s really a strange that doesn’t prompt to set the username and password . Because without setting the username and Password u can’t access to the PgAdmin Tool .
Thank you for answer.
I receive the message : ERROR pgadmin: The desktop user [email protected] was not found in the configuration database.
But if I do : find . -name ‘pgadmin4.db’, I receive nothing.
Your procedure worked on 15.10/pg 9.6 but doesn’t work on 16.04/pg 9.5.
What to do ?
Hi Michel,
The procedure should works fine on 16.04 Version, we applicate this procedure on Ubuntu 16.04 and works as sharm. I advice you to try to create a new virtual enviroment and install it again or Delete “pgadmin4.db” file & start pgAdmin4 again ( pgadmin4.db should be under the directory ~/.pgadmin/)
If you still having issues just leave a comment and we will try to fix it.
You can also take a look to this article where we explained how to install PGAdmin4 in server Mode: http://yallalabs.com/linux/how-to-install-pgadmin-4-in-server-mode-on-ubuntu-16-04-lts/
Thanks.
It’s possible to install it with ubuntu 14.04 version ? because i receive this message “Unable to find virtualenv package”. Thx
Hi Achref,
Yes of course you can installed on ubuntu 14.04, the “virtualenv” package is actually called “python-virtualenv” on 14.04, you need to install “python-virtualenv” package instead of “virtualenv” package using the following command:
# apt-get install python-virtualenv
Good luck!
Would really help if you could specify where ‘sudo’ is needed and where it is not. In step 2 you go into /opt/ and just do mkdir ? No sudo needed ? Also then you go to step 3 without saying anything about whether to come out of the pgadmin4 shell or execute the wget withing that shell ? Very confusing writeup
Ah nevermind. I wasn’t following the video just the writeup !! Thanks
Hi!, in the install (pip install pgadmin4-1.3-py2.py3-none-any.whl) marked the error: Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-U0ZaAJ/psycopg2/
Collecting psycopg2==2.6.2 (from pgadmin4==1.3)
Downloading psycopg2-2.6.2.tar.gz (376kB)
100% |████████████████████████████████| 378kB 1.1MB/s
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file ‘pip-egg-info/psycopg2.egg-info/SOURCES.txt’
Error: could not determine PostgreSQL version from ‘10.1’
—————————————-
Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-U0ZaAJ/psycopg2/
Could you help me to know that I failed?
Hi Lesly,
You are having problem with the installation of the package psycopg2, could you please tell us which version of python you are using ?
Try to download the version1.6 of pgadmin4
# wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.6/pip/pgadmin4-1.6-py2.py3-none-any.whl
# pip install pgadmin4-1.6-py2.py3-none-any.whl
Hope you resolve the problem.
Hi lotfi,
This solved problem for me, Thank you! In new version psycopg2 is upgraded to 2.7.
Hi Ivan,
We are glad that you resolved the problem, Subscribe in our youtube Channel to keep updated .
Nice video. I am running ubuntu on virtual box. I followed all the steps but got an error:127.0.0.1 can’t connect. Please how do I resolve
Hi, you should not close the virtual enviroment and obisouly python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py execution .
try to run it again if you close it and try to access
thanks!
configuration : uBUNTU 14.04, Postgres 10.1 , psycopg2.7
When I try to run either of the below command
# pip install pgadmin4-1.6-py2.py3-none-any.whl
or # pip install pgadmin4-2.1-py2.py3-none-any.whl
pgadmin4 folder is not generated even after successfully installing
Hi Nitin,
If you are trying to install it on ubuntu 14.04, the “virtualenv” package is actually called “python-virtualenv” on 14.04, you need to install “python-virtualenv” package instead of “virtualenv” package using the following command:
# apt-get install python-virtualenv
After that follow all the step of the installation make sure of course to activate the virtual environment .
Good luck!
Getting error while executing pgAdmin4.py script.
(pgadmin4) root@smart-Inspiron-5559:/opt/enviromentpy/pgadmin4# python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
Traceback (most recent call last):
File “lib/python2.7/site-packages/pgadmin4/pgAdmin4.py”, line 23, in
import config
File “/opt/enviromentpy/pgadmin4/lib/python2.7/site-packages/pgadmin4/config.py”, line 330, in
from config_local import *
File “/opt/enviromentpy/pgadmin4/lib/python2.7/site-packages/pgadmin4/config_local.py”, line 1
echo “SERVER_MODE = False” >> lib/python2.7/site-packages/pgadmin4/config_local.py
^
SyntaxError: invalid syntax
Hi Ketav,
Make sure sure that you are modifing the right file config_local.py and you are in the correct directory of your virtual environment
Hello everyone, my problem is when I try to execute pgAdmin4.py never show me set up to add my email address and password user account. I always get these lines:
/opt/environmentpy/pgadmin4/local/lib/python2.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use “pip install psycopg2-binary” instead. For details see: .
“””)
And I installed psycopg2-binary and all the dependencies that I need. Even though I can open pgadmin 127.0.0.0:5050 but obviously not require a login, just show me all the options.
Does anyone know what I’m doing wrong? Because when I installed in server mode (amazon) I did not have any problem and when I want to access require a login account.
Help me please
Hi Victor,
It’s really a bit strange, but we advice you to install the new version of PgAdmin that should be the PgAdmin4 v2.
Hi Mr. Lofti, I am trying to install PgAdmin4, it prompts for email-id and password. which email i have to type, as it doesnot have any website, for local , can i install server without email-id and password. Please guide me. Thank you
Hi Athreya,
It’s mandatory to provide an email address and a password to gain access to the pgadmin 4 web ui.
Hi Lotfi, can you help me with this
(pgadmin4) root@UltiMate:/opt/enviromentpy/pgadmin4/lib/python2.7/site-packages/pgadmin4# touch config_local.py
(pgadmin4) root@UltiMate:/opt/enviromentpy/pgadmin4/lib/python2.7/site-packages/pgadmin4# echo “SERVER_MODE = False” >> lib/python2.7/site-packages/pgadmin4/config_local.py
-bash: lib/python2.7/site-packages/pgadmin4/config_local.py: No such file or directory
btw FYI im following your solution to Lesly by downloading python1.6
sorry im a clear beginner in linux.
Thx
Im also using Ubuntu 18.04 e
Hi Lofti,
Can you help me with this
(pgadmin4) root@UltiMate:/opt/enviromentpy/pgadmin4/lib/python2.7/site-packages/pgadmin4# touch config_local.py
(pgadmin4) root@UltiMate:/opt/enviromentpy/pgadmin4/lib/python2.7/site-packages/pgadmin4# echo “SERVER_MODE = False” >> lib/python2.7/site-packages/pgadmin4/config_local.py
-bash: lib/python2.7/site-packages/pgadmin4/config_local.py: No such file or directory
FYI im following your instruction to Lesly by downloading python1.6 and im using Ubuntu 18.04
Sorry im an absolute beginner in Linux, Please help me
Thank you.
Hi Lofti,
Sorry I forgot to show you the error i found
ERROR: testtools 2.3.0 has requirement extras>=1.0.0, but you’ll have extras 0.0.3 which is incompatible.
ERROR: alembic 1.2.1 has requirement SQLAlchemy>=1.1.0, but you’ll have sqlalchemy 1.0.14 which is incompatible.
Hi Edward,
It’s better that you go with server mode installation steps that we already publish in our blog