Juliatzin
Juliatzin

Reputation: 19695

PGAdmin 4 not working anymore after postgresql Upgrade from v12 to v13

I just upgrade my ubuntu distribution from 20.10 to 21.04. On this process, my local postgres server were upgraded, from 12.x to 13.4

My local app is still working, but PGAdmin won't start anymore. Here's the log:

pgAdmin Runtime Environment
--------------------------------------------------------
Python Path: "/usr/pgadmin4/venv/bin/python3"
Runtime Config File: "/home/julien/.config/pgadmin/runtime_config.json"
pgAdmin Config File: "/usr/pgadmin4/web/config.py"
Webapp Path: "/usr/pgadmin4/web/pgAdmin4.py"
pgAdmin Command: "/usr/pgadmin4/venv/bin/python3 -s /usr/pgadmin4/web/pgAdmin4.py"
Environment: 
  - GJS_DEBUG_TOPICS: JS ERROR;JS LOG
  - LC_TIME: fr_FR.UTF-8
  - USER: julien
  - XDG_SESSION_TYPE: wayland
  - SHLVL: 0
  - HOME: /home/julien
  - OLDPWD: /home/julien
  - DESKTOP_SESSION: ubuntu
  - GIO_LAUNCHED_DESKTOP_FILE: /usr/share/applications/pgadmin4.desktop
  - GTK_MODULES: gail:atk-bridge
  - GNOME_SHELL_SESSION_MODE: ubuntu
  - LC_MONETARY: fr_FR.UTF-8
  - MANAGERPID: 2723
  - DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1000/bus
  - GIO_LAUNCHED_DESKTOP_FILE_PID: 409396
  - WAYLAND_DISPLAY: wayland-0
  - LOGNAME: julien
  - _: /usr/bin/gnome-session
  - rvm_bin_path: /usr/share/rvm/bin
  - JOURNAL_STREAM: 8:37688
  - XDG_SESSION_CLASS: user
  - USERNAME: julien
  - GNOME_DESKTOP_SESSION_ID: this-is-deprecated
  - PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/share/rvm/bin
  - SESSION_MANAGER: local/sunchain:@/tmp/.ICE-unix/2935,unix/sunchain:/tmp/.ICE-unix/2935
  - INVOCATION_ID: b0a4bd7f387b4b94b2d1ad6290b4faa6
  - LC_ADDRESS: fr_FR.UTF-8
  - XDG_RUNTIME_DIR: /run/user/1000
  - XDG_MENU_PREFIX: gnome-
  - GNOME_SETUP_DISPLAY: :1
  - DISPLAY: :0
  - LANG: en_US.UTF-8
  - LC_TELEPHONE: fr_FR.UTF-8
  - XDG_CURRENT_DESKTOP: ubuntu:GNOME
  - XDG_SESSION_DESKTOP: ubuntu
  - XMODIFIERS: @im=ibus
  - XAUTHORITY: /run/user/1000/.mutter-Xwaylandauth.OGNI80
  - SSH_AGENT_LAUNCHER: gnome-keyring
  - SSH_AUTH_SOCK: /run/user/1000/keyring/ssh
  - LC_NAME: fr_FR.UTF-8
  - SHELL: /usr/bin/zsh
  - QT_ACCESSIBILITY: 1
  - GDMSESSION: ubuntu
  - rvm_prefix: /usr/share
  - LC_MEASUREMENT: fr_FR.UTF-8
  - LC_IDENTIFICATION: fr_FR.UTF-8
  - rvm_version: 1.29.12 (manual)
  - GJS_DEBUG_OUTPUT: stderr
  - QT_IM_MODULE: ibus
  - PWD: /home/julien
  - XDG_DATA_DIRS: /usr/local/share/:/usr/share/:/var/lib/snapd/desktop
  - LC_NUMERIC: fr_FR.UTF-8
  - LC_PAPER: fr_FR.UTF-8
  - rvm_path: /usr/share/rvm
  - GDK_BACKEND: x11
  - NO_AT_BRIDGE: 1
  - PGADMIN_INT_PORT: 34035
  - PGADMIN_INT_KEY: dbb4e565-1e23-474d-bd74-c3d8606022cc
  - PGADMIN_SERVER_MODE: OFF
--------------------------------------------------------

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

What should I do to fix it ?

Upvotes: 5

Views: 14981

Answers (7)

LAamanni
LAamanni

Reputation: 177

Im here to tell you, you will have this python version mismatch problem again when you install ubuntu23. You will have python 3.11 and pgadmin will require python 3.10.

The solution for me was to install the docker version of pgadmin4. I could then connect to another docker (running on the same machine) using ssh tunnel.

I used to have gnome Sequeler but it has its own limitations and not so intensive development cycle as one would want.

Upvotes: 0

Abdinardo Oliveira
Abdinardo Oliveira

Reputation: 2755

I'm using Ubuntu 22.04, and the best way I could find was to install Python 3.8 using the following instructions, in this link How to Install Python 3.8 on Ubuntu 22.04 LTS. After that, it worked properly.

Upvotes: 1

Imnotapotato
Imnotapotato

Reputation: 5798

I had the same issue with pgadmin4. I think this happened somewhere when I updated my Ubuntu to 22.04, which updates python to python3.10, which is the reason why the app breaks (python3 points to the old python3.8). After changing the symlinc to python3.10, I got another python error. So before throwing my laptop out of the window, I just went and reinstalled (without uninstalling/removing) it from the official website and it updated all it needed in /usr/pgadmin4/env/bin (without deleting my saved database sessions).

I recommend this to be the best and fastest solution.

#
# Setup the repository
#

# Install the public key for the repository (if not done previously):
sudo curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add

# Create the repository configuration file:
sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

#
# Install pgAdmin
#

# 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 

# Configure the webserver, if you installed pgadmin4-web:
sudo /usr/pgadmin4/bin/setup-web.sh

Upvotes: 1

Javier A. Villalba
Javier A. Villalba

Reputation: 41

It's not a Postgres version issue, it's a Python version issue.

In my Debian case I had to execute ls -l at /usr/pgadmin4/venv/bin and see that the symlinks pointed to python3.9. My system had python3.10, I just had to add python3.9 and all fixed.

Upvotes: 4

Lokomotywa
Lokomotywa

Reputation: 2844

sudo apt install python3.8 helped me on Ubuntu 22.04

Upvotes: 4

Garrett Simpson
Garrett Simpson

Reputation: 1619

I ran into this on Ubuntu 21.10 (impish), and the accepted answer did not help. While in retrospect it is correct, it won't work unless you double check your apt sources aren't messed up, if you similarly screwed around with them; I had borked my installation paths thinking pgadmin4 wasn't fully installed when it was, trying to install past versions.

The problem stems from pgadmin4 assuming you have python3.8 installed; if you don't it will break.

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'  

Upvotes: 0

Laurenz Albe
Laurenz Albe

Reputation: 246033

The first thing you usually try in such a case is uninstall and reinstall the software...

Upvotes: 8

Related Questions