×

How to Update Python?

How to Update Python

In this article, we will discuss how we can update Python in our system.

For a better understanding, this article will cover all the steps right from installation to updating Python.

So, first, let's have a look at how we can install python on different operating systems-

Following are the steps for installing Python in Windows-

  1. Go to the website “Python.org”
How to Update Python
  1. You will find the ‘Downloads’ tab there and click on it to get the information related to the current version.
How to Update Python
  1. On clicking that, an executable file of Python will be downloaded.
  2. In the ‘Downloads’ folder, you will find the file and click on it for installation.
How to Update Python
  1. You will see the installation setup window of Python on your screen.
  2. Click on Install Now.
  3. On clicking this, a dialog box would appear named ‘User Account Control’, it will ask you ``Do you want to make changes to your device?”.
  4. Click on ‘Yes’ to start the installation process.
How to Update Python
  1. Once it is installed, we need an IDE (Integrated Development Environment) to write our programs in Python.
How to Update Python
  1. An IDE can help us to integrate the text editor with other essential features that can help in implementing various projects that earlier required complex coding.

Let's have a look at the steps that we must follow to install it in Linux-

  1. The first step here is to ensure that the list of packages is updated or not, which can be checked by writing the following command-

sudo apt update

  1. Once the packages are updated, the other essential thing is to have an idea about the prerequisites which can be verified using-

sudo apt install software-properties-common

  1. The next step here is to add deadsnakes PPA to our sources list.

Here one question that would strike in the mind of readers that what is 'Deadsnakes PPA'

So the answer for the same is that Deadsnakes PPA(Personal Package Archive) allows us to install multiple versions of Python in Ubuntu.

This particular thing can be implemented using the command-

sudo add-apt-repository ppa:deadsnakes/ppa

  1. Once we found out that the repository is enabled now we can initiate the installation process with the command given below-

sudo apt install python3.8

  1. So finally we have reached the stage where Python has been installed in Ubuntu successfully, if we again want to cross-check or verify its version, this can be done by writing the command given below-

python –version

The second method to install Python in Ubuntu is explained as follows-

Installing from source

  1. The first thing is to update the list of packages and install the ones which are important for building Python source-

sudo apt update

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

  • The next step is to download the latest version of Python from its download page using wget command

wget (Add the address of the latest version, you can obtain it from Python’s download page).

  • When the download process is completed, the next step is to extract the gzipped tarball:

tar -xf Python-3.7.4.tgz

  • The next thing to implement is running the configure script so that it can perform the required number of checks to ensure that all the necessary things on our system are present.

cd Python-3.7.4

./configure –enable-optimizations

  • So now what we have to do is start the python build process using make:

make -j 8

If you want your build time to be faster, you can adjust the -j flag based on your processor.

The number of cores in the processor can be found by typing nproc

  • Now we are done with the building process, next, we will install the python binaries with the help of commands written below-

sudo make altinstall

  • Finally, here we have successfully installed Python version 3.7.
  • The installed version can be verified using-

python3.7 –version

  • The output that will be displayed on our screen would be like-

Python 3.7.4

Now let's have a look at how we can update Python in Windows-

The steps for the same are-

  1. Go to the website “Python.org” and check its latest version.
  2. Click on the ‘Downloads’ tab and select ‘Windows’ from the given options.
  3. Scroll down the page and click on ‘Windows x86-64 executable installer.
  4. After the .exe file is successfully downloaded, a dialog box will appear which will ask you whether you would like to run the file. Click on the 'Run' option in that.
  5. After clicking that in the next dialog box, choose the option ‘Upgrade Now’.
  6. It will be updated successfully.
  7. We can verify it by typing the following command in Command Prompt-

python –version.

Now let’ see what are the steps to update Python in Linux-

  1. Check the version of python using-

$python3 –version

  • The latest version can be installed by typing-

    sudo apt install -y

    sudo apt install python_version(Write the name of the version here, for example, Python3.7)

  • We can add any two versions as update alternatives –

sudo update-alternatives--install/usr/bin/python3/usr/bin/python_version(Write the name of version here, for example Python3.7)

sudo update-alternatives--install/usr/bin/python3/usr/bin/python_version(Write the name of version here, for example Python3.7)

  • The next step is to configure Python 3 so that it works as the required version-

   sudo update-alternatives –config python3

So, in this article, we discussed how we can update Python in our system


Related Topics

How to Open a file in python with Path

In this tutorial, we will see rather than the traditional way of opening a file by locating or navigating it from our desktops; we will learn how to open the...

2 minutes read.

How to Plot Graphs Using Python?

In this article, we are going to learn about how to plot different types of graphs using Python. We are going to use different approaches for every type of graph....

3 minutes read.

Enumerate() Function in Python

The enumerate() function in Python is used to convert a data collection object into an enumerate object. It returns an object that contains a counter as a key for each...

3 minutes read.

How to get Time in seconds in Python

Python's time module source shows that are based on time. The time() method is used by developers and returns the current time as a UNIX timestamp. A UNIX timestamp is...

4 minutes read.

Handling missing keys in Python dictionaries

In this lesson, you will discover how to create a Python application that will manage missing keys in a dictionary. Python dictionaries store data as key-value pairs, where each value...

3 minutes read.

Python NewLine

In python, a new line character denoted by "\n" is known as an escape character or escape sequence, and it will force the cursor to change its position to the next...

6 minutes read.

Nested for Loop in Python

"Loop" is one of the foundation concepts to learn programming in any language. Nested loops are significant steps in solving many types of problems, ranging from basic to complex scenarios....

9 minutes read.

Python MySQL Database Connection

In this article, you will be able to understand how to connect to a MySQL database through Python. We generally can use many methods or modules to connect to the database...

6 minutes read.

Tuple in Python

Tuples Tuples are the same as the list but as we know that lists are mutable means we can change the data from it. In the tuple we cannot change the...

6 minutes read.

Python Program to Print Sum of all Elements in an Array

Python program to print sum of all elements in an array A set of objects stored in contiguous memory locations is referred to as an array. The concept is to keep...

2 minutes read.

Speech Recognition in Python

What is Speech Recognition? Speech Recognition is a term defined for automatic recognition of human speech. Speech recognition is the most significant activity in the domain of the interaction between the...

8 minutes read.

Alexa Python

The cloud-based voice assistant renders text into speech in a female voice. Alexa is a virtual assistant released by Amazon. Using itself as a system for home automation, Alexa can...

4 minutes read.

How to run a Program in Python

How to run a Program in Python Writing a program in Python is an easy task, beginners who are ready to kickstart their career in the world of programming can create...

3 minutes read.

Python Set clear() Method

Python Set clear() Method The set.clear() method removes all the elements from the set. Syntax set.clear() Parameter NA Return None Example 1 # Python program explaining # the set.clear() method # initializing the set fruits = {"watermelon", "banana", "apple"} # printing the set...

2 minutes read.

Import Function in Python

In Python programming language, the import keyword plays an important role in the whole code because it makes one module make available in another module. Import is used to structure...

3 minutes read.

Python program for perfect number

Python program for perfect number Before writing any program for a given problem, we have to understand the problem for which we are creating a solution program. So, let's understand what...

2 minutes read.

Yield Statement In Python

The generators are defined by using the yield statement in Python. Generally, it converts a normal Python function into a generator.  The yield statement hauls the function and returns back the...

2 minutes read.

Python Dictionary update() method

Python Dictionary update() method The dictionary.update() method in Python inserts the specified items to the dictionary. Syntax dictionary.update(iterable) Parameter iterable- This parameter represents a dictionary or an iterable object with key value pairs, that will...

1 minute read.

Python and its advantages

What is Python? Python is an object-oriented programming language, a general-purpose programming language with a high level, and also an interpreted language that has an easy syntax and dynamic semantics. Python...

7 minutes read.

Function annotations() in Python

What is Function Annotations? Function annotations provide a way related to different parts of a function at compile time with arbitrary Python expressions. It doesn’t have life in Python runtime execution....

3 minutes read.