17

I've installed postgresql 9.6 (using suggested linux installer) which comes with pgAdmin4, but getting a few errors.

First, I had to change the folder name from "pgAdmin 4" (note the extra space) to "pgAdmin4" to avoid "file not found error".

Then I run sudo python pgAdmin4.py and got the following error:

Traceback (most recent call last):
   File "../../pgAdmin4.py", line 24, in <module>
      from pgadmin import create_app
   File "/opt/PostgreSQL/9.6/pgAdmin4/web/pgadmin/__init__.py", line 17, in <module>
      from flask import Flask, abort, request, current_app
ImportError: No module named flask

I tried following this related question: Flask ImportError: No Module Named Flask -- managed to installed flask on virtualenv.

But then I started getting other flask related modules that are missing: flask_babel, flask_login, flask_security. I installed all of them using pip, but then I got an error on missing module htmlmin.minify which I can't seems to able to install.

Traceback (most recent call last):
   File "../pgAdmin4.py", line 24, in <module>
      from pgadmin import create_app
   File "/opt/PostgreSQL/9.6/pgAdmin4/web/pgadmin/__init__.py", line 23, in <module>
      from htmlmin.minify import html_minify
ImportError: No module named htmlmin.minify

I also exported PYTHONPATH to the one on flask, as described here, still getting the same error.

So, anyone have an idea how to make pgAdmin4 work on ubuntu environemt?

Elad Tabak
  • 2,317
  • 4
  • 23
  • 33
  • Have you installed virtualenv? Are you trying to do everything from inside the virtualenv? – Nurjan Dec 21 '16 at 10:05
  • I installed virtualenv but it might be that I'm not actually running from within that virtual env? how do I make sure? – Elad Tabak Dec 21 '16 at 10:07
  • You need to activate the virtualenv by running `. venv/bin/activate` where venv is the result of `virtualenv venv`. Insted dot, you can use command `source`. – Nurjan Dec 21 '16 at 10:08
  • Yes I run the environment, which caused the terminal to show prompt starting with the env name (flask). Still, getting an error. I suspect the pip installation was not done on the virtualenv. When I run pip install flask I'm getting an error on permissions, so I run it using sudo, but I think sudo causes it to be installed outside of the virtualenv. – Elad Tabak Dec 21 '16 at 10:17

7 Answers7

12

After following the documentation on adding PgAdmin 4 to my Fedora 28 failed in every possible way I went with the Docker option:

mkdir ~/.pgadmin4  # to store config and stuff
docker run -d --rm --network host -v ~/.pgadmin4:/pgadmin thajeztah/pgadmin4

Then go to http://localhost:5050 and you are done with it.

See https://github.com/thaJeztah/pgadmin4-docker for more info.

nyxz
  • 6,918
  • 9
  • 54
  • 67
  • 2
    This is by far the simplest solution. I now have Docker and pgAdmin4 runing on a Chromebook. For details on Chrombook Docker setup go follow these steps:Install Docker on Chromebook curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" sudo apt update sudo apt install docker-ce sudo usermod -a -G docker $USER – John Dauphine Feb 07 '20 at 21:42
10

According to https://www.pgadmin.org/download/pip4.php.

Install the virtualenv by running:

sudo apt-get install virtualenv

You also need to install these 2 libraries:

sudo apt-get install libpq-dev python-dev 

Then:

cd ~/bin/
virtualenv pgadmin4

I prefer to use the ~/bin/ directory for installing applications.

Then you download the pgadmin4-1.1-py2-none-any.whl or pgadmin4-1.1-py3-none-any.whl depending on the python version you use. For this example we use python 2.7.

You download pgadmin4:

wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.1/pip/pgadmin4-1.1-py2-none-any.whl

Activate the virtualenv:

. ~/bin/pgadmin4/bin/activate

After that you will see (pgadmin4) in the terminal.

Inside of pgadmin4 run:

pip install ./pgadmin4-1.1-py2-none-any.whl

After that you must be able to run pgadmin4:

python ~/bin/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py 

In order to make the running process a bit easier you can create an alias. For instance, in Ubuntu 16.04 LTS, add alias in the ~/.bash_aliases file:

alias pgadmin4='. /home/your_username/bin/pgadmin4/bin/activate; /home/your_username/bin/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py'

Where your_username should be replaced by your real user name.

Then give execute permission, for example, 764 to the pgAdmin4.py file in:

/home/your_username/bin/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py

Also you need to edit the pgAdmin4.py file and add this line in the very top:

#!/home/your_username/bin/pgadmin4/bin/python

where your_username is your real user name.

This will make sure that you run the application using the required version of python and include all necessary dependencies in order to run pgadmin4.

Then run . ~/.bashrc in order to apply the changes.

So now you can open your terminal and simply type pgadmin4 in order to run it.

Open your browser and point to:

http://127.0.0.1:5050

One more thing to note - if you need to run pgadmin4 in desktop mode you need to change SERVER_MODE to False in:

/home/your_username/bin/pgadmin4/lib/python2.7/site-packages/pgadmin4/config.py

Otherwise when you visit localhost:5050 it will ask you for your login and password.

UDPATE:

As of 2021 (and significantly earlier) a much better option would be to use a preconfigured docker container with pgadmin4 on it. For example, a pgadmin4 docker image can be downloaded from https://hub.docker.com/r/dpage/pgadmin4/.

Hope this helps.

Nurjan
  • 5,889
  • 5
  • 34
  • 54
  • So creating a directory with a virtualenv that you use and then starting it makes sense. What seems strange is that you then need to point to the file location within python 2.7's site packages to start the application. Doesn't this seem a little convoluted? Is this really the intended workflow that one must follow every time they want to start up PgAdmin4? – kuanb Jan 25 '17 at 18:43
  • 1
    @kuanb, According to the official website https://www.pgadmin.org/download/pip4.php you need to use that path in python 2.7' site packages in order to run pgadmin4. As a workaround I made an alias where I activate the virtualenv and then run the pgadmin4 and it works nicely. I will edit the answer to show how it works. – Nurjan Jan 26 '17 at 03:48
  • @Nurzhan I think you're missing "python" before calling the pgadmin4.py file in your alias definition. – newdimension Feb 05 '17 at 05:04
  • @newdimension No, you don't need `python` before calling `pgadmin4.py`. `pgadmin4.py` is an executable itself. – Nurjan Feb 05 '17 at 05:45
  • There is a mistake in this line. `wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.1/pip/pgadmin4-1.1-py2-none-any.whl` no need for pgadmin3 folder. The correct url should be, `https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.1/pip/pgadmin4-1.1-py2-none-any.whl` – neeraja Aug 18 '20 at 12:46
  • 2021-03-04 12:11:59 FEHLER 404: Not Found. – Stephan Kristyn Mar 04 '21 at 11:12
  • @SteveK There https://ftp.postgresql.org/pub/pgadmin/pgadmin4/ – pabgaran Mar 08 '21 at 09:37
  • For python 3 in 2022 pgadmin4 v1.1 is deprecated you can download new version with below command wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v6.6/pip/pgadmin4-6.6-py3-none-any.whl – sahil panindre May 04 '22 at 05:19
  • Thanks for including the link to the docker doc. – Pfinnn Jul 01 '22 at 15:06
3

Please, try these commands:

sudo apt-get install pgadmin4

sudo python3.5 /usr/share/pgadmin4/web/pgAdmin4.py
Vasilis G.
  • 7,556
  • 4
  • 19
  • 29
andrei040191
  • 408
  • 4
  • 7
  • 1
    and then you have to install every flask extension to your python 3.5 installation – Abdelouahab Jan 29 '18 at 19:36
  • `sudo apt-get install pgadmin4` is not working anymore as on the date this comment is posted. It gives an error `E: Package 'pgadmin4' has no installation candidate` – Suraj S Jain Jun 15 '19 at 16:32
0

On debian at least the web version is not depending on that sudo apt install pgadmin4-web. Know it could be that you need the rich client, but you can consider it as an alternative

Pipo
  • 4,653
  • 38
  • 47
0

for following link - ERROR 404: Not Found.

wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.1/pip/pgadmin4-1.1-py2-none-any.whl

use alternate link

wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.4/pip/pgadmin4-1.4-py2.py3-none-any.whl

also run reference

pip install pgadmin4-1.4-py2.py3-none-any.whl -U psycopg2
tushar zore
  • 101
  • 1
  • 8
0

You can following command for installation:

Install for both desktop and web modes:

sudo apt install pgadmin4

Install for desktop mode only:

sudo apt install pgadmin4-desktop

Install for web mode only:

sudo apt install pgadmin4-web

You can refer to below documentation: https://www.pgadmin.org/download/pgadmin-4-apt/

Twinkle Rastogi
  • 111
  • 1
  • 5
-1

If you use Windows, try to delete the folder: %APPDATA%\pgAdmin