×

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

Subprocess in Python

In this tutorial, we will understand what is a subprocess in python and will understand how to use it. Subprocess A subprocess is a very prevailing portion of the python library. It...

3 minutes read.

Cross Entropy in Python

Introduction Cross-entropy loss is frequently combined with the softmax function. Determine the total entropy among the distributions or the cross-entropy, which is the difference between two probability distributions. For the purpose...

5 minutes read.

Python e-book free download

Python is a booming language these days. It has many applications for making code easier; it is also an open-source language. There are many sources to learn python. In this...

3 minutes read.

Gaussian elimination in python

Linear and polynomial equations are used in almost all fields of numerical simulation. However, its most common use in engineering is in the area of linear system analysis. The broader...

3 minutes read.

How to slice a list in python

When working with lists, we face situations where we may need a part of the list from one index to the other. Slicing is one of the simpler ways to...

5 minutes read.

Python Empty Tuple

How to Create an Empty Tuple Tuple A tuple is a data structure used to store non-homogeneous data elements. These non-homogeneous data elements consist of integer data type, character data type, String...

3 minutes read.

Best resources to learn Numpy and Pandas in python

In this tutorial, we will discuss the different resources where we can learn about NumPy and Pandas libraries of Python in a more efficient way. NumPy NumPy, a Python library used for...

4 minutes read.

Django vs NodeJS

Django and NodeJS are open-source frameworks used to develop web applications. Both Django and NodeJS are cross-platform and robust technology used for developing versatile web applications and mobile applications. Django Django is...

2 minutes read.

Python Typing Module

An Introduction to the Typing Module The typing module is introduced in Python version 3.5 and used to provide hinting method types in order to support static type checkers and linters...

10 minutes read.

Python program to find the area of a circle

Python program to find the area of a circle This article will discuss how to find the area of a circle in Python with a given radius. The area of a...

2 minutes read.

Python Variables, Constants and Literals

Python is today's most valuable, easy-to-implement and sought-out programming language. Nowadays, developers want to focus on implementing the program rather than spending time with complex programs. So, for this reason,...

17 minutes read.

How to change a value of a tuple in Python

Python is the language for newly evolving technologies and has become one of the most popular programming languages in the world. It is used in everything right, from simple algorithm...

3 minutes read.

How to learn python Online

Need to Learn a Programming Language 1. To get a high Paying job We know that Software Engineering is one of the top-paying professions in the world. The top criteria to be...

3 minutes read.

SKLearn Linear Module

The SK learn linear module is one such module that helps to study the relationship between the independent and dependent variables.The linear module can be implemented by using the best...

3 minutes read.

Python Modules

Python Modules The Python module is a collection of definition and statements. It can contain functions, classes, and variables.  Combining the related code into a module makes the code easier to understand and use....

5 minutes read.

How to append a string in python

Adding or appending a string to another string is easy in Python. It is called concatenation and is a basic concept of strings in almost all programming languages. Ways to Append...

4 minutes read.

Unicode to String in Python

Python Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster way....

3 minutes read.

Idle python download for Windows

Here, we will be discussing how to get the answer to all questions related to installing Python on Windows. What is IDLE? Integrated Development and Learning Environment, or IDLE, is a shorthand....

3 minutes read.

GUI to Shut down, Restart and Logout from the PC using Tkinter in Python

GUI: One of the most significant factors that increased the usability of computer and digital technologies for common, less tech-savvy users is likely the development and widespread adoption of GUIs. GUIs...

4 minutes read.

Python tuple() function

Python tuple() function The tuple() function in Python creates a tuple object. Syntax tuple([iterable]) Parameter Iterable: This parameter represents a sequence, collection or an iterator object. Return This function returns a tuple object. Example 1 # Python Program explaining #...

1 minute read.