Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change the python version from default 3.5 to 3.8 of google colab

I downloaded python version 3.8 on google colab using:

!apt-get install python3.8

Now I want to change the default python version used in google colab uses from 3.6 to 3.8. how to do it??

I have read few ans but there are no updates...

like image 931
luckyCasualGuy Avatar asked Jul 30 '20 07:07

luckyCasualGuy


People also ask

How do I change Python version on Google Colab?

In Colab, we can enforce the Python version by clicking Runtime -> Change Runtime Type and selecting python3 . Note that as of April 2020, Colab uses Python 3.6. 9 which should run everything without any errors.

Does Google colab use Python 2 or 3?

Because of that, Colab is in the process of deprecating Python 2 runtimes; see https://research.google.com/colaboratory/faq.html#python-2-deprecation for details.

How do I update my colab version?

Each runtime gives you a fresh google colab. ! sudo update-alternatives --config python3 #after running, enter the row number of the python version you want. NOTE: As mentioned in the comments, the above commands just add a new python version to your google colab and update the default python.


2 Answers

Colab has default python 3.7 and alternative 3.6 (on 26.07.2021)

# Choose one of the given alternatives:
!sudo update-alternatives --config python3

# This one used to work but now NOT(for me)!
# !sudo update-alternatives --config python

# Check the result
!python3 --version

# Attention: Install pip (... needed!)
!sudo apt install python3-pip
like image 80
Jaja Avatar answered Nov 14 '22 22:11

Jaja


try these commands

!update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1

then

!update-alternatives --list python

this must display your downloaded python version

after that

!sudo update-alternatives --config python
## !Set python3.8 as default.

finally

!sudo update-alternatives --set python /usr/bin/python3.8

then check your default python version on colab

!python3 --version
like image 27
chamod rathnayake Avatar answered Nov 14 '22 22:11

chamod rathnayake