Method 1: Manually Installing Python
Some users may want manually install the latest version of Python on Ubuntu by building from the source code… To do that they will need to download the installer file and run the executable…
Before installing Python from its source code, you must first install some required packages that are needed to build Python from source.. To get these packages installed, run the commands below:
sudo apt update sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
After installing the above packages, go and download the latest release’s source code from the Python download page using the following wget command..
cd /tmp wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
At the time of writing this post, 3.7.2 is the latest Python version… If you find a later version on the site, you can download it instead…
After downloading the package, run the commands below extract the file and install..
tar -xf Python-3.7.2.tar.xz cd Python-3.7.2 ./configure --enable-optimizations
Next start the building process using the make command.. Replace the #1 with the number of CPU cores on your system for faster build time… My machine has 1 CPU core, so I use the make command with -j 1 option…
make -j 1 sudo make altinstall
Do not use the standard make install as it will overwrite the default system python3 binary…
After that, Python should be installed and ready to use…
To test if Python is installed and ready to use, run the commands below
python3.7 --version
You should see an output similar to the one below:
Python 3.7.2
That’s how you install Python from its source
Leave A Comment?