Solution:
sudo ln -s /usr/share/pyshared/lsb_release.py /usr/local/lib/python3.6/site-packages/lsb_release.py
Explain:
We can see in /usr/bin/lsb_release
#!/usr/bin/python3 -Es
# lsb_release command for Debian
# (C) 2005-10 Chris Lawrence <lawrencc@debian.org>
# This package is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 dated June, 1991.
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA
from optparse import OptionParser
import sys
import os
import re
import lsb_release
The key step is import lsb_release
, but the problem is Python 3.6
doesn't have this module.
So, you must have overrided python3
from python3.5
to python3.6
. That's why your lsb_release
is broken.
To verify it, we can see in python3.6
:
➜ ~ python3.6
Python 3.6.4 (default, Feb 6 2018, 16:57:12)
[GCC 5.4.0 20160609] 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'
then in python3.5
:
➜ ~ python3.5
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] 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'
where is this file:
➜ ~ ll /usr/lib/python3/dist-packages/lsb_release.py
lrwxrwxrwx 1 root root 38 Jul 7 2016 /usr/lib/python3/dist-packages/lsb_release.py -> ../../../share/pyshared/lsb_release.py
So, this module lsb_release
exist in python3.5
but not exist in python3.6
. And We find it eventually!
Now let's fix it through add a link to the original lsb_release.py
file!
It works for me!
in case you still need it.
first of all, it's never advisable to uninstall python. check for instance this link.
having said this, Ubuntu 16.04 does not depend (wasn't build) on Python 3.9 (check this out, for instance). thus, and in principle you shouldn't be having problems fully uninstalling it... as it was my case.
i had no troubles following these steps; which for you/me would be something like:
sudo apt-get clean
sudo apt-get autoremove --purge
sudo apt-get remove python3.9
sudo apt-get autoremove
good luck!
Best Answer
I don't know what "docs" you are reading nor what they say, but the
/usr/bin/python
is just a symbolic link to the default version of python, in this case 2.7, which is the result of just typingpython
on the terminal. This is the result of PEP 394 which defines thattype python
andfile /usr/bin/python
will confirm this.The reason for this arrangement other than the convention, is that the source package python-defaults in Xenial is the version 2.7.11, so the python symbolic link points to this version.
To use python 3 you have to be explicit and type
python3
in the command line, which is recommended in case you need an specific version, this can also be done with python 2, typingpython2
. Ubuntu includes both python 2 and 3 versions by default on all current versions.There are plans to migrate everything to python 3 and marking it as the default.