I think I have break my system by changing the default python.
So when I run : python --version
, I get: Python 3.5.3
When I run ls /usr/bin/python*
, I get:
/usr/bin/python /usr/bin/python2.7 /usr/bin/python2-config /usr/bin/python3.5 /usr/bin/python3.5m /usr/bin/python3-config /usr/bin/python3m-config
/usr/bin/python2 /usr/bin/python2.7-config /usr/bin/python3 /usr/bin/python3.5-config /usr/bin/python3.5m-config /usr/bin/python3m /usr/bin/python-config
By changing the default python, I am getting a lot of errors:
For example, when I run the command sudo apt-get autoremove
, the following appears:
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python-pep8 (1.7.0-4) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 38, in <module>
from debpython.namespace import add_namespace_files
File "/usr/share/python/debpython/namespace.py", line 120
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: error processing package python-pep8 (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
python-pep8
E: Sub-process /usr/bin/dpkg returned an error code (1)
I did try to go back by looking at the How to update-alternatives to Python 3 without breaking apt?
I tried: sudo update-alternatives --config python
But the results were:
There is only one alternative in link group python (providing /usr/bin/python): /usr/bin/python3
Nothing to configure.
How to go back to my default python?
EDIT:
Output of ls -l /usr/bin/python*
lrwxrwxrwx 1 root root 24 Mar 9 21:35 /usr/bin/python -> /etc/alternatives/python
lrwxrwxrwx 1 root root 9 Sep 23 2019 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3772872 Nov 23 2017 /usr/bin/python2.7
lrwxrwxrwx 1 root root 33 Nov 23 2017 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root 16 Jan 24 2017 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 9 Sep 23 2019 /usr/bin/python3 -> python3.5
-rwxr-xr-x 2 root root 4747720 Nov 23 2017 /usr/bin/python3.5
lrwxrwxrwx 1 root root 33 Nov 23 2017 /usr/bin/python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x 2 root root 4747720 Nov 23 2017 /usr/bin/python3.5m
lrwxrwxrwx 1 root root 34 Nov 23 2017 /usr/bin/python3.5m-config -> x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx 1 root root 16 Jan 20 2017 /usr/bin/python3-config -> python3.5-config
lrwxrwxrwx 1 root root 10 Sep 23 2019 /usr/bin/python3m -> python3.5m
lrwxrwxrwx 1 root root 17 Jan 20 2017 /usr/bin/python3m-config -> python3.5m-config
lrwxrwxrwx 1 root root 16 Jan 24 2017 /usr/bin/python-config -> python2.7-config