Python is a very popular language for all sorts of things like Web Development, Machine Learning (and Data Analysis), Scripting, and other areas. It has become one of the most popular programming languages on Earth with a large community of developers, so, lets get started.
- If you have come to this tutorial because your installation of python failed, run these commands (replace
<python_version>with the version of your broken installation):
sudo updatedb sudo rm -rfv /usr/local/bin/<python_version> # or /usr/bin/<python_version> sudo rm -rfv `locate <python_version>` sudo updatedb locate <python_version>
The last command should give you nothing.
python3.9is can be replaced with your python version.
- In order to install python fully, some tools to build python need to be installed, open up the terminal and type:
sudo apt update sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev tk-dev liblzma-dev lzma
- Download the latest version of python from the official python website or use
- Inflate the python
.tgzfile by typing:
tar -xf Python-3.9.0.tar.xz # or tar -xf Python-3.9.0.tgz rm -v Python-3.9.0.tar.xz # or rm -v Python-3.9.0.tgz
- Change Directory into the Python Folder and start configuring python by typing:
cd Python-3.9.0 ./configure --enable-optimizations
- To build python, run:
make -j `nproc` # Optimized for the number of processors the computer has
- To Install python, run:
sudo make altinstall
We use altinstall to avoid replacing other versions of python with this one (it tends to break things on the computer).
- Finally, to test if python was successfully installed, type:
python3.9 --version Python 3.9.0