Skip to main content
added 772 characters in body
Source Link
Stewart
  • 16k
  • 5
  • 48
  • 101

While add-apt-repository may be a python script, apt is, and dpkg are not and should still work for you:

$ file $(which add-apt-repository) $(which apt) $(which apt-cache) $(which dpkg)
/usr/bin/add-apt-repository: Python script, ASCII text executable
/usr/bin/apt:                ELF 64-bit LSB pie executable, x86-...
/usr/bin/apt-cache:          ELF 64-bit LSB pie executable, x86-...
/usr/bin/dpkg:               ELF 64-bit LSB pie executable, x86-

You can use apt to re-install / reconfigure the broken package including some broken links. I'm on Debian Testing, but the core python packages for Debian and Ubuntu are maintained by the same person, so I suspect it's similar for you. Here I'm looking for the relevant packages:

$ ls -lgo $(which python3) 
lrwxrwxrwx 1 root root 9 Dec 23 07:05 /usr/bin/python3 -> python3.9

$ dpkg -S $(which python3) $(which python3.9)
python3-minimal: /usr/bin/python3
python3.9-minimal: /usr/bin/python3.9

$ apt-cache show python3 | grep Depends:
Depends: python3.9 (>= 3.9.1-1~), libpython3-stdlib (= 3.9.1-1).
Pre-Depends: python3-minimal (= 3.9.1-1) 

$ apt-cache show python3.9 | grep Depends:
Depends: python3.9-minimal (= 3.9.1-4)...

Now we know which packages handle this link and the binaries associated with it. In your case, you are on Ubuntu 20.04, so you'll want python3.8-minimalpython3.8 instead of python3.9-minimalpython3.9.

$ sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3

ThatIf you get the same thing, it means alternatives no longer manage python3. I'm not sure when this changed, butif you don't get this could beit's probably why there's a problem on your machine. If you run this command When an old python3 version was removed, the prerm responsible for update-alternatives --remove python3 was never run. Try running update-alternatives --config python3 and check what options are available. If you have python3.8 as an option, and it's the highest priority, then rerun this as sudo and select auto.

$ sudo update-alternatives --config python3
There are 3 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                    Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.8      1111      auto mode
  1            /usr/bin/python3.5      1101      manual mode
  2            /usr/bin/python3.8      1111      manual mode
  3            /usr/bin/python3.7      1081      manual mode

However, I suspect python3.8 is not in your list and this is why you are having problems. Even with Debian buster (released in 2018), we had python3.7 so python3.5 is pretty old. Since the pythonpython3 packages now manage links on their own, when you ran update-alternatives --config python3 you probably replaced the good link with something that's out of date. In this case, I'd manually remove the python3 alternative with:

While add-apt-repository may be a python script, apt is not and should still work for you:

$ file $(which add-apt-repository) $(which apt)
/usr/bin/add-apt-repository: Python script, ASCII text executable
/usr/bin/apt:                ELF 64-bit LSB pie executable, x86-...

You can use apt to re-install / reconfigure the broken package. I'm on Debian Testing, but the core python packages for Debian and Ubuntu are maintained by the same person, so I suspect it's similar for you. Here I'm looking for the relevant packages:

$ ls -l $(which python3)
lrwxrwxrwx 1 root root 9 Dec 23 07:05 /usr/bin/python3 -> python3.9

$ dpkg -S $(which python3) $(which python3.9)
python3-minimal: /usr/bin/python3
python3.9-minimal: /usr/bin/python3.9

$ apt-cache show python3 | grep Depends:
Depends: python3.9 (>= 3.9.1-1~), libpython3-stdlib (= 3.9.1-1)
Pre-Depends: python3-minimal (= 3.9.1-1)
$ apt-cache show python3.9 | grep Depends:
Depends: python3.9-minimal (= 3.9.1-4)...

Now we know which packages handle this link and the binaries associated with it. In your case, you are on Ubuntu 20.04, so you'll want python3.8-minimal instead of python3.9-minimal.

$ sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3

That means alternatives no longer manage python3. I'm not sure when this changed, but this could be why there's a problem on your machine. If you run this command, check what options are available. If you have python3.8 as an option, and it's the highest priority, then select auto.

$ sudo update-alternatives --config python3
There are 3 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                    Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.8      1111      auto mode
  1            /usr/bin/python3.5      1101      manual mode
  2            /usr/bin/python3.8      1111      manual mode
  3            /usr/bin/python3.7      1081      manual mode

However, I suspect python3.8 is not in your list and this is why you are having problems. Even with Debian buster (released in 2018), we had python3.7 so python3.5 is pretty old. Since the python packages now manage links on their own, update-alternatives --config python3 probably replaced the good link with something that's out of date. In this case, I'd manually remove the python3 alternative with:

While add-apt-repository may be a python script, apt, and dpkg are not and should still work for you:

$ file $(which add-apt-repository) $(which apt) $(which apt-cache) $(which dpkg)
/usr/bin/add-apt-repository: Python script, ASCII text executable
/usr/bin/apt:                ELF 64-bit LSB pie executable, x86-...
/usr/bin/apt-cache:          ELF 64-bit LSB pie executable, x86-...
/usr/bin/dpkg:               ELF 64-bit LSB pie executable, x86-

You can use apt to re-install / reconfigure the broken package including some broken links. I'm on Debian Testing, but the core python packages for Debian and Ubuntu are maintained by the same person, so I suspect it's similar for you. Here I'm looking for the relevant packages:

$ ls -go $(which python3) 
lrwxrwxrwx 1 9 Dec 23 07:05 /usr/bin/python3 -> python3.9

$ dpkg -S $(which python3) $(which python3.9)
python3-minimal: /usr/bin/python3
python3.9-minimal: /usr/bin/python3.9

$ apt-cache show python3 | grep Depends:
Depends: python3.9 (>= 3.9.1-1~), ...
Pre-Depends: python3-minimal (= 3.9.1-1) 

$ apt-cache show python3.9 | grep Depends:
Depends: python3.9-minimal (= 3.9.1-4)...

Now we know which packages handle this link and the binaries associated with it. In your case, you are on Ubuntu 20.04, so you'll want python3.8 instead of python3.9.

$ update-alternatives --config python3
update-alternatives: error: no alternatives for python3

If you get the same thing, it means alternatives no longer manage python3. I'm not sure when this changed, if you don't get this it's probably why there's a problem on your machine. When an old python3 version was removed, the prerm responsible for update-alternatives --remove python3 was never run. Try running update-alternatives --config python3 and check what options are available. If you have python3.8 as an option, and it's the highest priority, then rerun this as sudo and select auto.

$ update-alternatives --config python3
There are 3 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                    Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.8      1111      auto mode
  1            /usr/bin/python3.5      1101      manual mode
  2            /usr/bin/python3.8      1111      manual mode
  3            /usr/bin/python3.7      1081      manual mode

However, I suspect python3.8 is not in your list and this is why you are having problems. Even with Debian buster (released in 2018), we had python3.7 so python3.5 is pretty old. Since python3 packages now manage links on their own, when you ran update-alternatives --config python3 you probably replaced the good link with something that's out of date. In this case, I'd manually remove the python3 alternative with:

added 772 characters in body
Source Link
Stewart
  • 16k
  • 5
  • 48
  • 101

What's special about this is that it re-invokes the scripts in /var/lib/dpkg/info/<package>.{pre,post}{inst,rm} which are responsible for performing any byte-compilation, and using update-alternatives (when appropriate).

Then re-install the python packages again.

Whenever a new python3 is released, there is some time spent running tests on all dependent packages in the archive. If a package fails, then bug reports are filed and maintainers do what they can to ensure their package works with the latest version of python3. You don't normally need to have multiple point-releases installed. terminator should work fine with the latest python3. I suspect it would have otherwise been removed from the archive if it failed the transition and never released with Ubuntu 20.04. The exception to this are PPAs (or any 3rd party repository), which are beyond the reach of the official distributions and could have anything in them including a version of terminator which only works with python3.5.

What's special about this is that it re-invokes the scripts in /var/lib/dpkg/info/<package>.{pre,post}{inst,rm} which are responsible for performing any byte-compilation, and using update-alternatives.

Then re-install the python packages again.

What's special about this is that it re-invokes the scripts in /var/lib/dpkg/info/<package>.{pre,post}{inst,rm} which are responsible for performing any byte-compilation, and using update-alternatives (when appropriate).

Then re-install the python packages again.

Whenever a new python3 is released, there is some time spent running tests on all dependent packages in the archive. If a package fails, then bug reports are filed and maintainers do what they can to ensure their package works with the latest version of python3. You don't normally need to have multiple point-releases installed. terminator should work fine with the latest python3. I suspect it would have otherwise been removed from the archive if it failed the transition and never released with Ubuntu 20.04. The exception to this are PPAs (or any 3rd party repository), which are beyond the reach of the official distributions and could have anything in them including a version of terminator which only works with python3.5.

Source Link
Stewart
  • 16k
  • 5
  • 48
  • 101

First, I suggest using a terminal which is not dependent on python. gnome-terminal or xterm would work:

$ file $(which terminator) $(which xterm) $(which gnome-terminal)
/usr/bin/terminator:     Python script, ASCII text executable
/usr/bin/xterm:          ELF 64-bit LSB pie executable, ...
/usr/bin/gnome-terminal: ELF 64-bit LSB pie executable, ...

While add-apt-repository may be a python script, apt is not and should still work for you:

$ file $(which add-apt-repository) $(which apt)
/usr/bin/add-apt-repository: Python script, ASCII text executable
/usr/bin/apt:                ELF 64-bit LSB pie executable, x86-...

You can use apt to re-install / reconfigure the broken package. I'm on Debian Testing, but the core python packages for Debian and Ubuntu are maintained by the same person, so I suspect it's similar for you. Here I'm looking for the relevant packages:

$ ls -l $(which python3)
lrwxrwxrwx 1 root root 9 Dec 23 07:05 /usr/bin/python3 -> python3.9

$ dpkg -S $(which python3) $(which python3.9)
python3-minimal: /usr/bin/python3
python3.9-minimal: /usr/bin/python3.9

$ apt-cache show python3 | grep Depends:
Depends: python3.9 (>= 3.9.1-1~), libpython3-stdlib (= 3.9.1-1)
Pre-Depends: python3-minimal (= 3.9.1-1)
$ apt-cache show python3.9 | grep Depends:
Depends: python3.9-minimal (= 3.9.1-4)...

Now we know which packages handle this link and the binaries associated with it. In your case, you are on Ubuntu 20.04, so you'll want python3.8-minimal instead of python3.9-minimal.

I would try to fix it with:

sudo apt reinstall python3 python3-minimal python3.8 python3.8-minimal

What's special about this is that it re-invokes the scripts in /var/lib/dpkg/info/<package>.{pre,post}{inst,rm} which are responsible for performing any byte-compilation, and using update-alternatives.

If this doesn't work, I'd take a look at the output of update-alternatives --config python3. On Debian testing I get:

$ sudo update-alternatives --config python3
update-alternatives: error: no alternatives for python3

That means alternatives no longer manage python3. I'm not sure when this changed, but this could be why there's a problem on your machine. If you run this command, check what options are available. If you have python3.8 as an option, and it's the highest priority, then select auto.

$ sudo update-alternatives --config python3
There are 3 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                    Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.8      1111      auto mode
  1            /usr/bin/python3.5      1101      manual mode
  2            /usr/bin/python3.8      1111      manual mode
  3            /usr/bin/python3.7      1081      manual mode

However, I suspect python3.8 is not in your list and this is why you are having problems. Even with Debian buster (released in 2018), we had python3.7 so python3.5 is pretty old. Since the python packages now manage links on their own, update-alternatives --config python3 probably replaced the good link with something that's out of date. In this case, I'd manually remove the python3 alternative with:

sudo update-alternatives --remove-all python3

Then re-install the python packages again.