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.
Warning:
- 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.
Note:
-
python3.9
is can be replaced with your python version.
Preparation:
- 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
Installation:
- Download the latest version of python from the official python website or use
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
- Inflate the python
.tar.gz
or.tgz
file 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
This should look something like this:
Image Of Python Configuring
- To build python, run:
make -j `nproc` # Optimized for the number of processors the computer has
It should look like this:
Image of Python being built
- 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).
This should look like:
Sudo Make Altinstall Process
- Finally, to test if python was successfully installed, type:
python3.9 --version
Python 3.9.0
Top comments (0)