Most of the coders or developers use Google Colab for executing their codes very fast as it provides you access to faster GPUs like the T4 and P100 if resources are available at a very cheap rate. But v buck generator sometimes your code requires a specific version of the package to be installed. If you want to change the version of python in Google colab then you have come to the right place. In this tutorial, you will learn how to change the python version in Google Colab.
You have installed the specific python version in Google Colab let’s say it is 3.10. Now you want to change the version of python to 3.7 then how you can do so. You will know the methods to do so in the next sections.
How to change the python version in google colab
Before changing the version of the python in Google Colab let’s check the current version of the python installed in the collab. Use the below lines of code to check that
Steps to change the Python version of the Google Colab
Step 1: Update the alternatives for the python
The first step is to define the alternatives for the python you want to install the python version. It will install the specific python version in the colab. Here I will install python version 3.7
Type the below command in your cell of the Google colab notebook to change the version.
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
Step 2: Configure the python
The second step is to configure the python version. Use the below command to do so.
!sudo update-alternatives --config python3
It will ask the to type the selection number. Choose the number corresponding to your version. It will change the version of python. In this example, it is 3.7 so type 3 and enter.
Step 3: Check the result
Now after all the above steps check the version of python to verify.
At last, you have to install python to permanently install the specific version to the google colab.
!sudo apt install python3-pip
Sometimes a specific version of python is required to v buck generator work for the python modules. If there is a requirement to change the version in the Google Colab then the above steps will change the version of python.
I hope you have liked this tutorial. If you have any queries then you can contact us for more help.
Join our list
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.