5

i installed pgAdmin but when i open it i get this error :

Failed to launch pgAdmin4. Error:
Error: spawn /usr/pgadmin4/venv/bin/python3 ENOENT

when i tap this command :

sudo python3 /usr/share/pgadmin4/web/pgAdmin4.py

i get

python3: can't open file '/usr/share/pgadmin4/web/pgAdmin4.py': [Errno 2] No such file or directory

then i create the missing file path as,

sudo mkdir -p /var/cache/pgadmin/sessions

and run this command again

sudo python3 /usr/share/pgadmin4/web/pgAdmin4.py

but i get the same error

Garrett Simpson
  • 147
  • 1
  • 10
ingmbk
  • 59

3 Answers3

1

Ran into this on Ubuntu 21.10 (impish), because I had borked my installation paths thinking pgadmin4 wasn't fully installed when it was.

The error is because it is assuming python3.8 is installed (21.10 comes with python3.9) , but it isn't, so all the symlinks and virtual env fails. But this is happening because you've installed a version of pgadmin4 that doesn't match your Ubuntu version.

garrett@garrett-external:/etc/apt/sources.list.d$ ls
deadsnakes-ubuntu-ppa-impish.list  pgadmin4.list.save  pgdg.list.save
pgadmin4.list                      pgdg.list

##Looking at pgadmin4.list.save , I see I had at least tried to use

hirsute 's repo:

garrett@garrett-external:/etc/apt/sources.list.d$ cat pgadmin4.list.save deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/hirsute pgadmin4 main

##I'm thinking this is overriding the correct impish repos, so I'll

try deleting that file, purging the installation and re-installing:

garrett@garrett-external:/etc/apt/sources.list.d$ ls deadsnakes-ubuntu-ppa-impish.list pgadmin4.list pgadmin4.list.save pgdg.list pgdg.list.save garrett@garrett-external:/etc/apt/sources.list.d$ sudo rm pgadmin4.list.save

##double check that the pgadmin4 sources are correct... garrett@garrett-external:/etc/apt/sources.list.d$ ls deadsnakes-ubuntu-ppa-impish.list pgadmin4.list pgdg.list pgdg.list.save garrett@garrett-external:/etc/apt/sources.list.d$ cat pgadmin4.list deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 main

##^ok definitely the problem...should fix that....

garrett@garrett-external:/etc/apt/sources.list.d$ sudo sed -i 's/focal/impish/g' /etc/apt/sources.list.d/pgadmin4.list garrett@garrett-external:/etc/apt/sources.list.d$ cat ./pgadmin4.list deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/impish pgadmin4 main

##uninstall pgadmin4 garrett@garrett-external:/etc/apt/sources.list.d$ sudo apt purge pgadmin4 garrett@garrett-external:/etc/apt/sources.list.d$ sudo apt autoremove

##reinstall pgadmin4 garrett@garrett-external:/etc/apt/sources.list.d$ sudo apt update && sudo apt install pgadmin4

And now it works fine

EDIT: DON'T GO DOWN THE RABBIT HOLE BELOW

Workaround: Manually install python3.8 using the deadsnakes PPA and some temporary apt cache updating trickery

  #first add deadsnakes ppa...
  $  sudo add-apt-repository ppa:deadsnakes

Following the gist of https://brennan.io/2021/06/21/deadsnakes-hirsute/ ,

update the deadsnakes ppa's app repos to look at the past 2 LTS versions

$ sudo vim /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa-impish.list ---> change 'deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu/ impish main' to 'deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu/ bionic main' , also add 'deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu/ focal main'

#Add the following rules which blacklist all packages from

the repos, and then selectively enable Python versions from the correct

locations. This can be put in any filename within the directory

/etc/apt/preferences.d/ (I named mine deadsnakes_pref)

Explanation: Prevent installing from deadsnakes repo. Package: * Pin: release o=LP-PPA-deadsnakes Pin-Priority: 1

Explanation: Allow installing python 3.{6,7} from deadsnakes/focal Package: python3.6 python3.7 Pin: release o=LP-PPA-deadsnakes,n=focal Pin-Priority: 500

Explanation: Allow installing python 3.8 from deadsnakes/bionic Package: python3.8 Pin: release o=LP-PPA-deadsnakes,n=bionic Pin-Priority: 500

##temporarily change all your sources to bionic, so the python3.8 #dependencies will be met $ sudo sed -i 's/impish/bionic/g' /etc/apt/sources.list

try to update the apt cache and install python3.8 . You'll get yelled

at for not having the proper key ring:


W: GPG error: http://us.archive.ubuntu.com/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32 E: The repository 'http://us.archive.ubuntu.com/ubuntu bionic InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.


so following

https://askubuntu.com/questions/13065/how-do-i-fix-the-gpg-error-no-pubkey

, I add the key

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32

now this should work

$ sudo apt update && sudo apt install python3.8

#after we're done, don't forget to change back your sources $ sudo sed -i 's/bionic/impish/g' /etc/apt/sources.list $ sudo apt update

#And now pgadmin4 should work. If you want to run it from the terminal,

add this line to your ~/.bash_aliases file:

alias pgadmin4='/usr/pgadmin4/bin/pgadmin4'

Garrett Simpson
  • 147
  • 1
  • 10
0

Just install the Pgadmin again and it will fix the broken links after the OS upgrade ;)

If you want instructions, you can follow the ones from here: https://computingforgeeks.com/how-to-install-pgadmin-4-on-ubuntu/

Mr.Coffee
  • 141
0

This problem may happen because the Python version 3.8 used in pgAdmin, but you have different Python version installed. For me the fix was to install older Python 3.8. Before applying the fix check the explanation, to ensure you have same issue.

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.8

The pgAdmin worked fine afterwards. The newer Python version I have installed before, worked fine too.

Here the explanation

While reading the first lines of error output I found the installation folder is:

/usr/pgadmin4/venv/bin

I changed current catalog to this folder with:

$ cd /usr/pgadmin4/venv/bin

and checked content with:

$ ls -al
lrwxrwxrwx 1 root root     7 Sep 20 09:47 python -> python3
lrwxrwxrwx 1 root root    18 Sep 20 09:47 python3 -> /usr/bin/python3.8

As you see link refers to Python 3.8. However it is not installed. My installed python version was

$ python3 -V
Python 3.10.12

So I installed python 3.8 to fix the link:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.8

Now pgAdmin 4 application was able to start.

P_M
  • 171