2

Everything that depends on the lsb_release command is not working on my computer.

example:

pip install numpy

raise subprocess.CalledProcessError(code, cmd, stdout, stderr) subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1

And in fact, lsb_release -a generates an error

File "/usr/bin/lsb_release", line 95, in <module>
    main()
  File "/usr/bin/lsb_release", line 59, in main
    distinfo = lsb_release.get_distro_information()
  File "/usr/lib/python3/dist-packages/lsb_release.py", line 383, in get_distro_information
    distinfo = guess_debian_release()
  File "/usr/lib/python3/dist-packages/lsb_release.py", line 281, in guess_debian_release
    get_distro_info(distinfo['ID'])
  File "/usr/lib/python3/dist-packages/lsb_release.py", line 41, in get_distro_info
    RELEASES_ORDER.sort(key=lambda n: float(n[0]))
  File "/usr/lib/python3/dist-packages/lsb_release.py", line 41, in <lambda>
    RELEASES_ORDER.sort(key=lambda n: float(n[0]))
ValueError: could not convert string to float: '8.04 LTS'

I know that in python '8.04 LTS' cannot be converted to a float, but why is this happening.

I've tried to reinstall both lsb_release and python-pip but this does not fix the problem.

I'm on Ubuntu 16.04 LTS. any help ?

Ghilas BELHADJ
  • 162
  • 1
  • 9

2 Answers2

3

I had the same error on one of my VMs, the other 2 and hypervisor were fine. Same release (16.04.3), not a clue what caused it. It's a known bug.

I got some relief here

Modify the file /usr/share/pyshared/lsb_release.py line 41 from:

RELEASES_ORDER.sort(key=lambda n: float(n[0])) 

to:

RELEASES_ORDER.sort(key=lambda n: float(n[0].split()[0]))

Fixed the problem for me. Complete credit to SHIINA Hideaki (shiina) at Ubuntu bug launchpad. I'm just reposting it here.

muru
  • 197,895
  • 55
  • 485
  • 740
0

The problem occurs when I run lsb_release -a

Traceback (most recent call last):
  File "/usr/bin/lsb_release", line 95, in <module>
    main()
  File "/usr/bin/lsb_release", line 59, in main
    distinfo = lsb_release.get_distro_information()
  File "/usr/lib/python3/dist-packages/lsb_release.py", line 398, in get_distro_information
    distinfo = guess_debian_release()
  File "/usr/lib/python3/dist-packages/lsb_release.py", line 288, in guess_debian_release
    get_distro_info(distinfo['ID'])
  File "/usr/lib/python3/dist-packages/lsb_release.py", line 48, in get_distro_info
    RELEASES_ORDER.sort(key=lambda n: float(n[0]))
  File "/usr/lib/python3/dist-packages/lsb_release.py", line 48, in <lambda>
    RELEASES_ORDER.sort(key=lambda n: float(n[0]))
ValueError: could not convert string to float: '6.06 LTS'

and Let's check the file /usr/lib/python3/dist-packages/lsb_release.py

try:
    csvfile = open('/usr/share/distro-info/%s.csv' % origin.lower())
except FileNotFoundException:
    # Unknown distro, fallback to Debian
    csvfile = open('/usr/share/distro-info/debian.csv')

....

RELEASES_ORDER = list(RELEASE_CODENAME_LOOKUP.items()) RELEASES_ORDER.sort(key=lambda n: float(n[0]))

It loads the file /usr/share/distro-info/%s.csv, and convert the first item into float type, which may contants string like 'LTS'. So I modify the line 48 of /usr/lib/python3/dist-packages/lsb_release.py as follows, it works for me.

RELEASES_ORDER.sort(key=lambda n: (n[0]))