0

Platform: Ubuntu 20.04.4 LTS

When I run the lsb_release -a command, I get this error.

# lsb_release -a
Traceback (most recent call last):
File "/usr/bin/lsb_release", line 25, in <module>
    import lsb_release
ModuleNotFoundError: No module named 'lsb_release'

The first line of my file /usr/bin/lsb_release has this.

#!/usr/bin/python3 -Es

This is closely related to the problem given in this question. But the symnlink proposed solution proposed there does not helps me. I tried creating both of these two symlinks.

sudo ln -s /usr/share/pyshared/lsb_release.py /usr/local/lib/python3.9/site-packages/lsb_release.py

sudo ln -s /usr/share/pyshared/lsb_release.py /usr/local/lib/python3.8/site-packages/lsb_release.py

Here are the module search paths (I have python3.9, 3.8 and 2.7 on my laptop):

# python3
Python 3.9.5 (default, Nov 23 2021, 15:27:38) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lsb_release
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'lsb_release'
>>> exit()

python3.8

Python 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import lsb_release Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'lsb_release' >>> exit()

python2.7

Python 2.7.18 (default, Jul 1 2022, 12:27:04) [GCC 9.4.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import lsb_release >>> lsb_release.file '/usr/lib/python2.7/dist-packages/lsb_release.py' >>> exit()

1 Answers1

0

For 20.04 the python3 version should be 3.8.2-0ubuntu2. It works fine for me:

doug@s19:~/kernel/linux$ python3
Python 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lsb_release
>>> lsb_release.__file__
'/usr/lib/python3/dist-packages/lsb_release.py'
>>> exit()
doug@s19:~/kernel/linux$

and

doug@s19:~/kernel/linux$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal
Doug Smythies
  • 15,448
  • 5
  • 44
  • 61
  • 3
    Thank you. This helped to clarify in identifying the file path location of lsb_release.py in the python3 folder. On further investigation I was able to see that the symlink of the python3/dist-package/lsb_relase.py file was broken. I deleted that file, and created a new symlink as follow sudo ln -s /usr/share/pyshared/lsb_release.py /usr/lib/python3/dist-packages/ – jalaluddin Jul 20 '22 at 20:33