How can I use Python 2 on Google Colab?
Solution 1
You can use these 2 shortcuts to create a Python 2 Colab.
bit.ly/colabpy2
colab.to/py2
They will forward to this URL.
https://colab.research.google.com/notebook#create=true&language=python2
Solution 2
Python 2 reached its end of life on January 1, 2020, and is no longer supported by the Python developer community. 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.
Presently, there is no way to change to Python 2 via the Colab UI, but existing Python 2 notebooks will still connect to Python 2 for the time being. So, for example, if you open a notebook like this one: https://colab.research.google.com/gist/jakevdp/de56c474b41add4540deba2426534a49/empty-py2.ipynb and execute code, it will execute in Python 2 for now. I would suggest following that link, and then choosing File->Save A Copy In Drive to get your own copy of an empty Python 2 notebook.
But please be aware that at some point in the future, Python 2 runtimes will be entirely unavailable in Colab, even for existing notebooks that specify Python 2 in their metadata.
Related videos on Youtube
Prachi
Updated on July 09, 2022Comments
-
Prachi almost 2 years
How can I use the earlier version of Python i.e version 2.x?
Under the 'change runtime' option - I can see the option for selecting hardware accelerator.
-
Prachi about 4 yearsThanks for sharing , how did you created it? I have not been able to access the Runtime type option earlier.
-
korakot about 4 yearsThe option is removed. But this is the direct link to the old menu: "Create Python 2 Notebook".
-
S P Sharan over 2 yearsThe colab link does not work any more as of today.