Python

How to install Anaconda or Miniconda in Colab

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.

Anaconda installation

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:

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

This way the path to the packages managed through conda has been appended to the PYTHONPATH environment variable.

Miniconda installation

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:

!wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh

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.

Published on Web Code Geeks with permission by Guglielmo Iozzia, partner at our WCG program. See the original article here: How to install Anaconda or Miniconda in Colab

Opinions expressed by Web Code Geeks contributors are their own.

Guglielmo Iozzia

Guglielmo is currenty a Big Data Delivery Lead at Optum Ireland. He has been a software engineer and architect for a variety of Java and Scala applications (Big Data, web, cloud, web services, mobile). Since 2018 he is also a frequent speaker to international conferences. His first technical book is going to be published in December 2018
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Thanakon
Thanakon
4 years ago

Thank You for This ! I literally just registered this thing to thank you, and sorry for accidentally click thumb down It doesn’t let me change – –

Back to top button