11

Some python packages wont work in python 3.7 . So wanted to downgrade the default python version in google colab.Is it possible to do? If so how to proceed.Please guide me..

B.Thushar Marvel
  • 139
  • 1
  • 2
  • 9
  • Duplicate of https://stackoverflow.com/questions/52467489/is-there-a-way-to-use-python-3-5-instead-of-3-6 – esqew Mar 24 '21 at 06:48
  • 1
    Does this answer your question? [Is there a way to use Python 3.5 instead of 3.6?](https://stackoverflow.com/questions/52467489/is-there-a-way-to-use-python-3-5-instead-of-3-6) – Alex Metsai Mar 24 '21 at 07:57

3 Answers3

11

You could install python 3.6 with miniconda:

%%bash

MINICONDA_INSTALLER_SCRIPT=Miniconda3-4.5.4-Linux-x86_64.sh
MINICONDA_PREFIX=/usr/local
wget https://repo.continuum.io/miniconda/$MINICONDA_INSTALLER_SCRIPT
chmod +x $MINICONDA_INSTALLER_SCRIPT
./$MINICONDA_INSTALLER_SCRIPT -b -f -p $MINICONDA_PREFIX

And add to path:

import sys
_ = (sys.path.append("/usr/local/lib/python3.6/site-packages"))
RJ Adriaansen
  • 9,131
  • 2
  • 12
  • 26
2
!apt-get install python3.6

!update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
!update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

!python3 -V
douyu
  • 2,377
  • 2
  • 14
  • 27
0

The following code snippet below will download Python 3.6 without any Colab pre-installed libraries (such as Tensorflow). You can install them later with pip, like !pip install tensorflow. Please note that this won't downgrade your default python in colab, rather it would provide a workaround to work with other python versions in colab. To run any python scripts with 3.6 version, use !python3.6 instead of !python

!add-apt-repository ppa:deadsnakes/ppa
!apt-get update
!apt-get install python3.6
!apt-get install python3.6-dev

!wget https://bootstrap.pypa.io/get-pip.py && python3.6 get-pip.py

import sys

sys.path[2] = '/usr/lib/python36.zip'
sys.path[3] = '/usr/lib/python3.6'
sys.path[4] = '/usr/lib/python3.6/lib-dynload'
sys.path[5] = '/usr/local/lib/python3.6/dist-packages'
sys.path[7] ='/usr/local/lib/python3.6/dist-packages/IPython/extensions'
  • I got this error : `ERROR: This script does not work on Python 3.6 The minimum supported Python version is 3.7. Please use https://bootstrap.pypa.io/pip/3.6/get-pip.py instead.` Replace the link with `https://bootstrap.pypa.io/pip/3.6/get-pip.py` instead and make sure you deleted the _get-pip.py_ that was downloaded previously before executing. – El Bachir May 01 '23 at 17:28