Python is one of the most popular programming languages in the world. With its simple and easy to learn syntax Python is a great choice for beginners and experienced developers. Python is quite versatile programming language, can be used for many purposes like building games, developing websites…
This tutorial describes how to install Python 3.7 the latest version of Python on Ubuntu 18.04 LTS or Ubuntu 16.04 LTS using the apt tool or by building from a source code.
Prerequisites
You’ll need to be logged in as a user with sudo access to be able to install Python on your Ubuntu system.
Installing Python 3.7 using deadsnakes PPA
01- Start by updating the packages list and installing the prerequisites like below:
sudo apt update sudo apt install software-properties-common
02- Next, add the deadsnakes PPA
to your sources list and press Enter
to continue:
:
# sudo add-apt-repository ppa:deadsnakes/ppa Press [ENTER] to continue or Ctrl-c to cancel adding it.
03- Once the deadsnakes PPA
is added, install Python with the following command:
# sudo apt install python3.7
04- Finally you installed Python 3.7, you can verify the version by typing:
# python3.7 --version Python 3.7.2
Installing Python 3.7 from Source
01- First update the packages list and install the required packages to build Python from source:
sudo apt update sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
02- Download the latest release’s source code from the Python download page using the following wget
command, the latest release is 3.7.2:
# wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
03- Once download is complete, extract the tarball:
tar -xf Python-3.7.2.tar.xz
04- Next, navigate to the Python source directory and run the configure
script which will perform a number of checks to make sure all of the dependencies on your system are present:
# cd Python-3.7.2 # ./configure
05- Now use the following command to build the Python binaries by typing, if you want to overwrite the default system python3 binary use instead make install
:
# sudo make altinstall
06- Finally you installed Python 3.7, you can verify the version by typing:
# python3.7 --version Python 3.7.2
Conclusion
You have successfully installed Python 3.7 on your Ubuntu 18.04 server using PPA or Building from source. This guide can be applied for Ubuntu 16.04 and any Ubuntu based distribution or Debian distribution.
You might want to check the following guides:
- How To Install Apache Tomcat 9 Server on Ubuntu 18.04 LTS Bionic Beaver
- How to Install Zabbix Server 4 on Ubuntu 18.04 LTS Bionic Beaver
- How to install MariaDB 10 Server on Ubuntu 18.04 LTS Bionic Beaver
- How To Install PostgreSQL 11 on Ubuntu 18.04 LTS Bionic Beaver
We hope this tutorial was enough Helpful. If you need more information, or have any questions, just comment below and we will be glad to assist you!
PS. If you like this post please share it with your friends on the social networks using the buttons below.Thanks.