2

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...

luckyCasualGuy
  • 371
  • 1
  • 10
  • You have to use a local runtime, previously answered here: https://stackoverflow.com/a/52472939/12510050 – mpw2 Jul 30 '20 at 07:48
  • @mpw2 I know i saw that too... but I dont want to use local runtime cauz all my other scripts are designed for collab! I mean there will be breaking changes for me :( – luckyCasualGuy Jul 30 '20 at 07:50
  • Does this answer your question? [Install Python 3.8 kernel in Google Colaboratory](https://stackoverflow.com/questions/60775160/install-python-3-8-kernel-in-google-colaboratory) – Nic Wanavit Sep 08 '20 at 17:53

2 Answers2

0

In my opinion there is no "good" way to do this. What you can do is start your script with a shebang line. A shebang line will set the python version for the following code. Find some related answers and informations here. How do I tell a Python script to use a particular version

Find here some informations on how to use shebang in colab. https://colab.research.google.com/github/jhermann/blog/blob/master/_notebooks/2020-02-28-env_with_arguments.ipynb#scrollTo=SYv4FagrzLVu

When you have script for more versions of python you might come across this issue. Dealing with multiple python versions when python files have to use #!/bin/env python

tifi90
  • 348
  • 2
  • 12
0

try these commands

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

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