I wanted to make python3 my default on rhel so I followed the following at How to set Python3.5.2 as default Python version on CentOS?
sudo ln -fs /usr/bin/python3 /usr/bin/python
It changed the default to 3.6.8
root@rhel:~# python -V
Python 3.6.8
Then I tried yum install python-pip:
root@rhel:~# yum install python-pip
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
This happened when I tried a few other commands. I tried reverting the changes by
root@rhel:~# sudo ln -fs /usr/bin/python /usr/bin/python
But am running into
root@rhel:~# python -V
bash: /usr/bin/python: Too many levels of symbolic links
I guess from what Im reading in places I need to break the sym links. The following is whats in my /usr/bin/
ls -l /usr/bin | grep python
lrwxrwxrwx 1 root root 15 Oct 21 14:12 python -> /usr/bin/python
lrwxrwxrwx 1 root root 14 Aug 8 05:53 python-config -> python2-config
lrwxrwxrwx 1 root root 9 Aug 8 05:51 python2 -> python2.7
lrwxrwxrwx 1 root root 16 Aug 8 05:53 python2-config -> python2.7-config
-rwxr-xr-x 1 root root 7144 Jun 11 10:34 python2.7
-rwxr-xr-x 1 root root 1835 Jun 11 10:34 python2.7-config
lrwxrwxrwx 1 root root 9 Aug 8 05:51 python3 -> python3.6
lrwxrwxrwx 1 root root 16 Aug 8 05:53 python3-config -> python3.6-config
lrwxrwxrwx 1 root root 20 Aug 8 05:53 python3-debug -> /usr/bin/python3.6dm
-rwxr-xr-x 2 root root 11336 Jun 11 15:17 python3.6
lrwxrwxrwx 1 root root 17 Aug 8 05:53 python3.6-config -> python3.6m-config
-rwxr-xr-x 1 root root 11336 Jun 11 15:17 python3.6dm
-rwxr-xr-x 1 root root 175 Jun 11 15:16 python3.6dm-config
-rwxr-xr-x 1 root root 3396 Jun 11 14:54 python3.6dm-x86_64-config
-rwxr-xr-x 2 root root 11336 Jun 11 15:17 python3.6m
-rwxr-xr-x 1 root root 173 Jun 11 15:16 python3.6m-config
-rwxr-xr-x 1 root root 3403 Jun 11 14:54 python3.6m-x86_64-config
this line of the result
lrwxrwxrwx 1 root root 15 Oct 21 14:12 python -> /usr/bin/python
tells us that the symbolic link python
points to itself which is giving you the "Too many levels" error.
you can remove the link via
rm python
or reset the link to python3 using
ln -fs /usr/bin/python3 /usr/bin/python
(probably need sudo for both of these)
The yum
install error is a separate issue, though