How to Install Python 3 on Ubuntu 18.04 or 20.04 {Step-by-Step}

Using Different Versions of Python introduction
Python is a popular scheduling terminology much used to write scripts for operating systems. It ’ randomness versatile enough for use in vane development and app blueprint .
In this tutorial you will learn how to install Python 3.8 on Ubuntu 18.04 or Ubuntu 20.04.

How to install Python 3 on Ubuntu. Prerequisites

  • A system running Ubuntu 18.04 or Ubuntu 20.04
  • A user account with sudo privileges
  • Access to a terminal window/command-line (CtrlAltT)
  • Make sure your environment is configured to use Python 3.8

Option 1: Install Python 3 Using apt (Easier)

This process uses the apt package manager to install Python. There are fewer steps, but it ’ sulfur pendent on a third party hosting software updates. You may not see new releases as quickly on a third-party depository .
Most factory versions of Ubuntu 18.04 or Ubuntu 20.04 come with Python pre-installed. Check your version of Python by entering the comply :

python --version

If the revision level is lower than 3.7.x, or if Python is not installed, continue to the following step .

Step 1: Update and Refresh Repository Lists

Open a terminal window, and enter the follow :

sudo apt update

Step 2: Install Supporting Software

The software-properties-common software gives you better control over your package coach by letting you add PPA ( Personal Package Archive ) repositories. Install the supporting software with the command :

sudo apt install software-properties-common

install additional software for python

Step 3: Add Deadsnakes PPA

Deadsnakes is a PPA with newer releases than the default option Ubuntu repositories. Add the PPA by entering the trace :

sudo add-apt-repository ppa:deadsnakes/ppa

The system will prompt you to press insert to continue. Do then, and allow it to finish. Refresh the package lists again :

sudo apt update

Step 4: Install Python 3

now you can start the installation of Python 3.8 with the command :

sudo apt install python3.8

Allow the march to complete and verify the Python adaptation was installed sucessfully : :

python --version

Check Python version to confirm installation.

Option 2: Install Python 3.7 From Source Code (Latest Version)

Use this march to download and compile the reservoir code from the developer. It ’ s a act more complicated, but the tradeoff is accessing a newer handout of Python .

Step 1: Update Local Repositories

To update local repositories, use the dominate :

sudo apt update

Step 2: Install Supporting Software

Compiling a package from source code requires extra software .
Enter the follow to install the command packages for python :

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

Step 3: Download the Latest Version of Python Source Code

To download the newest release of Python Source Code, voyage to the /tmp directory and use the wget command :

cd /tmp
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz

Download the Latest Version of Python Source Code.
Note: The source code is different from the software found on the main download page. At the time this article was written, Python 3.7.5 was the latest version available.

Step 4: Extract Compressed Files

following, you need to extract the tgz file you downloaded, with the command :

tar -xf Python-3.8.3.tgz

Step 5: Test System and Optimize Python

Before you install the software, make certain you test the system and optimize Python .
The ./configure dominate evaluates and prepares Python to install on your organization. Using the --optimization option speeds code execution by 10-20 % .
Enter the following :

cd python-3.8.3
./configure --enable-optimizations

This step can take up to 30 minutes to complete .

Step 6: Install a Second Instance of Python (recommended)

To create a second installation of Python 3.835, in addition to your current Python installation, enter the follow :

sudo make altinstall

It is recommended that you use the altinstall method acting. Your Ubuntu system may have software packages dependent on Python 2.x .

(Option) Overwrite Default Python Installation 

To install Python 3.8.3 over the top of your existing Python, enter the be :

sudo make install

Allow the process to complete .

Step 7: Verify Python Version

Enter the pursue :

python3 --version


Note: If you are starting with Python and are placid looking for the proper IDE or editor program, see our comprehensive overview of the best Python IDEs and code editors .

Using Different Versions of Python

If you used the altinstall method, you have two different versions of Python on your arrangement at the lapp time. Each installation uses a different command .
Use the python command to run commands for any older Python 2.x translation on your system. For model :

python --version

To run a command using the newer version, use python3. For case :

python3 --version

It is possible to have multiple major ( 3.x or 2.x ) versions of Python on your system. If you have Python 3.7.x and Python 3.8.x both installed, use the second finger to specify which version you want to use :

python3.7 --version
python3.8 --version

conclusion
You should now have a work facility of Python 3 on your Ubuntu system. adjacent, consider installing PIP for Python if you haven ’ thyroxine already .
With everything set, you can start with some basics scripts like getting the stream fourth dimension and date in Python or learn file handling in Python with built-in methods, which include creating, first step, and closure files .

source : https://thefartiste.com
Category : Tech

About admin

I am the owner of the website thefartiste.com, my purpose is to bring all the most useful information to users.

Check Also

articlewriting1

Manage participants in a zoom meeting webinar

Call the people who attend the meet as follows Alternate host host Who scheduled the …

Leave a Reply

Your email address will not be published.