Install Python 3.8 kernel in Google Colaboratory

we can also use kora pip library

!pip install kora
import kora.install.py38

Update: Originally answered on 2020-03-29, but this answer is now outdated, see the answers above.

Based on these previous answers*, it seems that Google only supports python 2.7 and python 3.6 right now (as of 2020-03-29). However, if you must use python 3.8 you could connect to a local runtime: https://research.google.com/colaboratory/local-runtimes.html

*Previous answers:

  • Use latest Python version on Google Colab
  • How to force google colab to run in particular python version
  • Google Colab - Choosing specific Python version
  • Is there a way to use Python 3.5 instead of 3.6?
  • Python 3.5 in google colab

I have found how to run Python 3.8 notebook on Colab.

  • install Anaconda3
  • add (fake) google.colab library
  • start jupyterlab
  • access it with ngrok

Here's the code

# install Anaconda3
!wget -qO ac.sh https://repo.anaconda.com/archive/Anaconda3-2020.07-Linux-x86_64.sh 
!bash ./ac.sh -b

# a fake google.colab library
!ln -s /usr/local/lib/python3.7/dist-packages/google \
       /root/anaconda3/lib/python3.8/site-packages/google

# start jupyterlab, which now has Python3 = 3.8
!nohup /root/anaconda3/bin/jupyter-lab --ip=0.0.0.0&

# access through ngrok, click the link
!pip install pyngrok -q
from pyngrok import ngrok
print(ngrok.connect(8888))

For ipykernel to work in a colab notebook you need the google-colab package to be installed. If not it silently fails (you can notice the problem by running !python -m ipykernel_launcher).

Simply add the line !conda install -q -y google-colab -c conda-forge and it should work.

!wget -O mini.sh https://repo.anaconda.com/miniconda/Miniconda3-py38_4.8.2-Linux-x86_64.sh
!chmod +x mini.sh
!bash ./mini.sh -b -f -p /usr/local
!conda install -q -y jupyter
!conda install -q -y google-colab -c conda-forge
!python -m ipykernel install --name "py38" --user

You can test this solution in this fixed notebook

Don't forget to reload the browser page after you installed the kernel (as explained in the original post).