Colab is the Google’s platform for working with Python notebooks and practice Deep Learning using different frameworks. It is a powerful platform, there is availability of GPUs or TPUs, it allows to use your Google Drive space for notebooks and data, has a friendly user interface and lots of useful features, but in order to install/update Python packages, it comes by default only with pip and no availability for conda. If you need to import a Python package which is available in Anaconda, but not in PyPi you need to install Anaconda or Miniconda yourself from a notebook. In this post I am explaining the simple steps to do it.
Create your notebook and from a code cell download the Anaconda installer:
!wget -c https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
This is the version that works fine for me. I have tried also with the latest release 2019.10, but the configuration then would have extra complexity.
Now you need to make the downloaded file executable:
!chmod +x Anaconda3-5.1.0-Linux-x86_64.sh
and then you can run it:
!bash ./Anaconda3-5.1.0-Linux-x86_64.sh -b -f -p /usr/local
Before installing packages, a last configuration setting is needed:
This way the path to the packages managed through conda has been appended to the PYTHONPATH environment variable.
In most cased Miniconda would be enough. This is the way you can install it.
Create your notebook and from a code cell download the installer:
Make it executable:
!chmod +x Miniconda3-4.5.4-Linux-x86_64.sh
and finally execute it.
!bash ./Miniconda3-4.5.4-Linux-x86_64.sh -b -f -p /usr/local
And you’re ready to go.