Installing python
Installing python 3.8 on Ubuntu 20.04.5
First, update and upgrade:
Add PPA for Python old versions. The old versions of Python such as 3.9, 3.8, 3.7, and older are not available to install using the default system repository of Ubuntu 22.04 LTS Jammy JellyFish or 20.04 Focal Fossa. Hence, we need to add a PPA offered by the “deadsnakes” team to get the old archived Python versions easily.
Check python versions you want. Syntax:
In my case:
Install the version you want:
Set up a default version in your system:
Other methods
No very orthodox but:
Installing python in Kali
If you are on Ubuntu 19.10 (or any other version unsupported by the deadsnakes PPA, like it's the case of Kali), you will not be able to install using the deadsnakes PPA.
First, install development packages required to build Python.
Then download the tarball and extract it:
Once the Python tarball has been extracted, navigate to the configure script and execute it in your Linux terminal with:
The configuration may take some time. Wait until it is successfully finishes before proceeding.
If you want to create an alternative install for python, start the build process:
If you want to replace your current version of Python with this new version, you should uninstall your current Python package using your package manager (such as apt or dnf) and then install:
Installing pip
If you get error: externally-managed-environment, then the solution is create an environment. As the message explains, this is actually not an issue with Python
itself, but rather your Linux distribution (Kali, Debian, etc.) implementing a deliberate policy to ensure you don't break your operating system and system packages by using pip
(or Poetry, Hatch, PDM or another non-OS package manager) outside the protection of a virtual environment.
Creating a virtual environment
See virtual Environments.
Switch python versions
See pyenv.
Last update: 2024-03-29 Created: January 1, 2023 21:59:36