4

I have Python 2.7.15+ symlinked to python and Python 3.6.7 symlinked to python3. When I try to upgrade Ubuntu to 19.04 with

sudo do-release-upgrade

it returns the following error:

Traceback (most recent call last):
  File "/tmp/ubuntu-release-upgrader-k7w2kx7r/disco", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeMain.py", line 238, in main
    if app.run():
  File "/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeController.py", line 2085, in run
    return self.fullUpgrade()
  File "/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeController.py", line 1906, in fullUpgrade
    if not self.askLivepatch():
  File "/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeController.py", line 1175, in askLivepatch
    version = next((r.version for r in di.get_all("object") if r.series == self.toDist), self.toDist)
AttributeError: 'UbuntuDistroInfo' object has no attribute 'get_all'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/problem_report.py", line 497, in add_to_existing
    self.write(f)
  File "/usr/lib/python3/dist-packages/problem_report.py", line 450, in write
    block = f.read(1048576)
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

Original exception was:
Traceback (most recent call last):
  File "/tmp/ubuntu-release-upgrader-k7w2kx7r/disco", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeMain.py", line 238, in main
    if app.run():
  File "/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeController.py", line 2085, in run
    return self.fullUpgrade()
  File "/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeController.py", line 1906, in fullUpgrade
    if not self.askLivepatch():
  File "/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeController.py", line 1175, in askLivepatch
    version = next((r.version for r in di.get_all("object") if r.series == self.toDist), self.toDist)
AttributeError: 'UbuntuDistroInfo' object has no attribute 'get_all'

I tried to upgrade all Python packages before upgrading Ubuntu:

pip freeze --local | grep -v '^-e' | cut -d = -f 1  | xargs -n1 pip install -U

Is that why it fails?

2
  • I'm back on this question because I got this problem upgrading 19.10 to 20.04.
    – user677955
    Apr 24, 2020 at 21:56
  • and once again 20.04 to 20.10
    – user677955
    Oct 22, 2020 at 20:22

2 Answers 2

6

This seems to typically stem from a pip-installed version of distro-info shadowing the apt version [...]

If you're here looking for a quick fix:

sudo python3 -m pip uninstall distro-info
sudo apt reinstall python3-distro-info

https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1874250/comments/9

2
  • 3
    Ran into this upgrading 20.04 to 20.10 and can confirm that this works
    – user677955
    Oct 22, 2020 at 20:22
  • 1
    Ran into this problem in 2022 trying to upgrade from 20.04 to 22.04 LTS and it still works :). Thank you! Aug 9, 2022 at 22:07
6

I solved the question by myself.

I find the problemed python script:

/usr/local/lib/python3.6/dist-packages/distro_info.py

Then cover it by:

https://salsa.debian.org/debian/distro-info/raw/master/python/distro_info.py

then run sudo do-release-upgrade, successfully.

1
  • this seems a bit unsafe, @Ahmed's answer is safer.
    – user677955
    Oct 22, 2020 at 20:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .