How to install / use Conda on Google Colab

In this article we will see how to install and use the conda package manager on Google Colab !

Conda is an open source system that allows you to manage independent environments and install libraries / packages.

It is an ideal tool to create specific environments for development, testing or even production as it allows you to create “sandbox” spaces.

So, when doing Machine Learning, it can be interesting to use Conda and create free and independent environments.

As we are Google Colab adepts which allows us to code Python on the Cloud, we will see how to use Conda on this platform.

Google Colab

Is conda already installed?

First of all, I recommend that you to check that conda is not already installed.

To do this, we check the version of conda ! Obviously if it is not installed, the code will return an error :

!conda --version

You should have : /bin/bash: conda: command not found

Install conda

To install conda, a library has been created specifically for Google Colab, conda-colab, and fortunately for us it is very easy to use !

You just have to install it with the pip command, then install conda with the condacolab.install() function.

By the way, if your goal is to master Deep Learning - I've prepared the Action plan to Master Neural networks. for you.

7 days of free advice from an Artificial Intelligence engineer to learn how to master neural networks from scratch:

  • Plan your training
  • Structure your projects
  • Develop your Artificial Intelligence algorithms

I have based this program on scientific facts, on approaches proven by researchers, but also on my own techniques, which I have devised as I have gained experience in the field of Deep Learning.

To access it, click here :

GET MY ACTION PLAN

GET MY ACTION PLAN

Now we can get back to what I was talking about earlier.

!pip install -q condacolab
import condacolab
condacolab.install()

Once the installation is complete, the kernel should have rebooted itself and you’ll get :

Conda has been installed. To ensure it, we may display the version of Conda :

!conda --version

The code should return something like : conda 4.9.2.

You can also look at the location of the conda folder you just installed with this command :

!which conda

That’s it ! You can now use conda on Google Colab as you wish!

Be careful though, every time you quit or reset the runtime environment you will have to install conda again.

That’s why I advise you to always have this piece of code at hand :

!conda --version
#If !conda --version returns no results, install conda with :
#!pip install -q condacolab
#import condacolab
#condacolab.install()

Other tips are waiting for you in this section, feel free to have a look 😉

Photo by Thomas Evans on Unsplash

One last word, if you want to go further and learn about Deep Learning - I've prepared for you the Action plan to Master Neural networks. for you.

7 days of free advice from an Artificial Intelligence engineer to learn how to master neural networks from scratch:

  • Plan your training
  • Structure your projects
  • Develop your Artificial Intelligence algorithms

I have based this program on scientific facts, on approaches proven by researchers, but also on my own techniques, which I have devised as I have gained experience in the field of Deep Learning.

To access it, click here :

GET MY ACTION PLAN

GET MY ACTION PLAN

Tom Keldenich
Tom Keldenich

Artificial Intelligence engineer and data enthusiast!

Founder of the website Inside Machine Learning

6 Comments

  1. Excellent! Thanks. This article should be ranked before those from medium.com or towardsdatascience.com

  2. After doing this, I can not activate the conda environment. How can i slove this problem?

  3. Same problem here.
    Environment is not reachable anymore after restarting kernel message

Leave a Reply

Your email address will not be published. Required fields are marked *

This page will not stay online forever

Enter your email to receive for free

The PANE method for Deep Learning

* indicates required

 

You will receive one email per day for 7 days – then you will receive my newsletter.
Your information will never be given to third parties.

You can unsubscribe in 1 click from any of my emails.



Entre ton email pour recevoir gratuitement
la méthode PARÉ pour faire du Deep Learning


Tu recevras un email par jour pendant 7 jours - puis tu recevras ma newsletter.
Tes informations ne seront jamais cédées à des tiers.

Tu peux te désinscrire en 1 clic depuis n'importe lequel de mes emails.