How to change the python version used on google colab

I’m trying to install this repo :

https://github.com/CMU-Perceptual-Computing-Lab/MonocularTotalCapture

on google colab. This is how I have installed conda and opencv=2.4.13 (it requires python 2.7 to work)

pip install conda

!wget -c https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
!chmod +x Anaconda3-5.1.0-Linux-x86_64.sh

!bash ./Anaconda3-5.1.0-Linux-x86_64.sh -b -f -p /usr/local

import sys

sys.path.append('/usr/local/lib/python3.6/site-packages/')

!conda install -y -q -c conda-forge opencv=2.4.13

Between the others packages,it requires also pyEDM,so I’m trying to install it. I’m following this guide :

https://github.com/SugiharaLab/pyEDM/issues/1

I don’t get any error until this command :

!cd pyEDM; pip install .

that gives to me this error :

Processing /content/pyEDM
ERROR: Package 'pyEDM' requires a different Python: 2.7.15 not in '>=3'

Infact when I ask which versions of python I have,it says :

!python2 --version
Python 2.7.15

!python3 --version
Python 3.6.9

!echo $PYTHONPATH
/tensorflow-1.15.0/python3.6:/env/python

So,I should change the python version installed by conda when I have installed opencv 2.4.13 to a version of 3 or greater,otherwise the package can’t be installed. On my local machine I would do that with this command :

!alias python='/usr/bin/python3.6'

but it does not work on colab. When I give the alias command it doesn’t answer anything and the error is still there.

What can I do ?

Leave a Reply