ABOUT

i installed python3 in my kali 2019.1 version .i also have python2.7 for some programs which works only in python2 . i tried to jump back to my python 2 for those programs by :

 sudo update-alternatives --config python

but i got

ERROR

 update-alternatives: error: no alternatives for python

SIMILARLY

 sudo update-alternatives --config python2.7

ERROR

 update-alternatives: error: no alternatives for python2.7

i also tried

 sudo update-alternatives --install /usr/bin/python python /usr/bin/    python2.7 2

ERROR

 update-alternatives: priority must be an integer

but when i typed

 python2 --version

output is

 Python 2.7.15+

Question

how can i switch between python 2.7 and python 3 ?

1 Answers

-1
Matt On

update-alternatives

The update-alternatives command is used for setting the default program to use (like choosing the default webbrowser or default python version). If you want the python command to use python 3 you can run:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 5

python versions

If you need to switch versions regularly it's probably simpler to switch between python 3 and 2.7 by using the python2 and python3 commands respectively.

[email protected]:~# python2 --version
Python 2.7.15+
[email protected]:~# python3 --version
Python 3.6.7