Kali Linux – How to upgrade python 2.7 to python 3.7

I have covered changing the default version of python in Debian, however for those looking to Google for a quick fix on Kali, I hope that this reaches you well.

This was tested on a completely fresh install of Kali Linux with no other alterations made prior.

The basic premise is to configure Kali to use python 3.7 at a higher priority to python 2.7 or any other version installed on the system.

Check your python version

Step 1 is to check your current python version:

python -V


python --version

Kali default output:
Python 2.7.17

Set your Python Default

Now it is time configure the priority for the versions of python that we have installed, 2.7 and 3.5/7. You can list all of the available alternatives installed by running:

ls /usr/bin/python*

To set your version priorities, with 3.7 being the high priority:

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

We have just set 3.7 (2) to have a priority great than 2.7 (1). Now when we list the python priorities we see see 3.7 is higher that 2.7:

update-alternatives --config python

This is also a great way to easily switch those priorities around once they have been set.

Check you default version, again…

python -V

Now this command should return the default which you configured above.

Other Useful Python tips:

Exitcode0 Tip Jar

If you have found this guide useful or it has solved a burning issue for you, please consider throw a coin in the tip jar to help this site stay active:


4 Replies to “Kali Linux – How to upgrade python 2.7 to python 3.7”

  1. I still see the following:

    (base) root@kali:~/Desktop/For_lab10# update-alternatives –config python
    There are 2 choices for the alternative python (providing /usr/bin/python).

    Selection Path Priority Status
    * 0 /usr/bin/python3.6 2 auto mode
    1 /usr/bin/python2.7 1 manual mode
    2 /usr/bin/python3.6 2 manual mode

    Press to keep the current choice[*], or type selection number:
    (base) root@kali:~/Desktop/For_lab10# python -V
    Python 2.7.16 :: Anaconda, Inc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: