Upgrade Python 2.7 to Python 3.9.0 in Kali Linux
How to Upgrade Python 2.7 to Python 3 in Kali Linux
In this post, am going to show you how to upgrade Python 2.7 to python 3 in Kali Linux without any errors (Import error, bash: pip: command not found).
Python 3.9.0 is the newest major release of the Python programming language, and it contains many new features and optimizations.
Why Python 3?
Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
Python 2.7 Bugs:
Python 2.7 causes lot of bugs due to end of life. Most of the users are encountered by the following two errors.
ImportError is raised when an
import statement has trouble successfully importing the specified module. Typically, such a problem is due to an invalid or incorrect path.
Traceback (most recent call last): File "mountain.py", line 28, in ? from toolkit.interface import interface ImportError: No module named toolkit.interface
When I ran any commends in Linux terminal the UnicodeDecodeError message was showed. It is a python DPKG error. In your system any python packages are missing, then you was encountered by this error. During executing python, you was encountered by this error.
E: problem executing scripts APT::update:post-invoke-success file /usr/share/commnd-not-found/CommandNorFound/db/creator.py UnicodeDecodeError: 'utf-8' code can't decode byte 0xed in position 15: Invalid continuation byte E: sub process returned an error code
Upgrade Python 2.7 to 3.9.0 :
- Remove Python 2.7
- Install Python 3.9.0
- Install PIP3
- Check the version of Python
Step 1 : Remove Python 2.7
Open a terminal and type the following command for removing python 2.7 packages.
mk007@linuxlia:~$ sudo apt purge -y python2.7-minimal
Step 2 : Install Python 3
Open a terminal and run the following commands for installing python 3.9.0
mk007@linuxlia:~$ sudo ln -s /usr/bin/python3 /usr/bin/python
Step 3 : Install PIP
Now run the following commands for installing PIP.
mk007@linuxlia:~$ sudo apt install -y python3-pip mk007@linuxlia:~$ sudo ln -s /usr/bin/pip3 /usr/bin/pip
Step 4 : Check the Version
Check the version python using the below command.
mk007@linuxlia:~$ python --version
If you have any doubts about this post please leave a comment otherwise ping me in Instagram. Am ready to solve your doubts.