Python 3.8 is the latest major version of the Python language. It includes many new features, such as an assignment expression, only positional parameters, f string support, and so on.
The same steps apply to Ubuntu 16.04 and any Ubuntu-based distributions, including Kubuntu, Linux Mint and Elementary OS.
Use Apt install Python 3.8 on Ubuntu
Using apt to install Python 3.8 is a relatively simple procedure on Ubuntu, just a few minutes:
01, run the following command as root user or a user has sudo access to update the package list and install the prerequisites:
sudo apt update
sudo apt install software-properties-common
02, to add to the list of sources deadsnakes PPA system:
sudo add-apt-repository ppa:deadsnakes/ppa
When prompted, press Enter to continue:
Package Penalty for AT Sources are the Available at The:
https://github.com/deadsnakes/
more information: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
press [ENTER] to continue or Ctrl-c to cancel the installation.
03, after the repository is enabled, use the following command to install Python 3.8:
sudo apt install python3.8
04, by typing the following command to verify the installation was successful:
Output:
Python 3.8.0
So far, Python 3.8 is installed on the Ubuntu system, you can start using it.
Python 3.8 from source mounted on Ubuntu
In this section, we will explain how to compile from source Python 3.8.
01, the package list and install the update packages that are required to build Python:
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
02, using wget to download the latest version from the download page Python source code:
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
At this writing, the latest version is 3.8.0.
03, after the download is complete, unzip the compressed archive:
tar -xf Python-3.8.0.tgz
04, switch to Python source directory and execute the configure script, which perform a number of checks to ensure that all dependencies are present on the system:
cd Python-3.8.0
./configure --enable-optimizations
--enable-optimizations options to optimize Python binary file by running more tests. This will slow down the build process.
05, start the Python 3.8 build process:
make -j 8
In order to speed up the time to build, -j modify the core so as to correspond to the number of processors. You can find the number by typing nproc.
06, after the build process is complete, enter the following command to install Python binaries:
sudo make altinstall
Do not use the standard make install, because it overrides the default system python3 binaries.
07, only. Python 3.8 is installed and ready to use. Be verified by typing the following:
python3.8 --version
The output should show the version of Python:
Output Python 3.8.0
to sum up
You have installed Python 3.8 on Ubuntu 18.04 computer, then you can start developing Python 3 project.