How to setup and run Conda on Google Colab

Google Collaboratory, or Google Colab, is a free cloud-based platform by Google to write and execute Python code in a web-based environment. It is based on the Jupyter Notebook and is supported by graphics processing units (GPUs) and Tensor Processing Units (TPUs). Google Colab can be used to train machine learning models.

Conda is an open-source package management tool to install, update, and manage libraries and packages. It can also create and manage isolated environments. Moreover, it is useful for installing various libraries or packages when working on projects with different requirements. In this Answer, we will explore all the required steps for installing Conda in Google Colab, learn to create environments, and install packages for different environments.

Installing Conda

To install Conda in Google Colab, a Python package, condacolab, is used, which provides an easy way to install Conda. We first install the condacolab package using the pip command. After installation, we import the condacolab package and, by using it, call the install() function, which automatically installs the Conda into the Google Colab notebook.

!pip install -q condacolab
import condacolab
condacolab.install()
Installing Conda using the condacolab package

To verify the Conda installation, we can run the command given below. If Conda is installed correctly, it will output its version. Otherwise, it will throw the error “command not found.”

!conda --version
Verifying the Conda installation

Note: Every time you quit or reset the runtime, you wil need to install Conda again.

After successfully installing Conda, we can locate the Conda package by running the command below. It will print the path where Conda is installed.

!which conda
Locating Conda

Once Conda is installed, we can install packages or create isolated environments.

#Installing the packages
!conda install pandas numpy matplotlib
#creating the environment
!conda create --name envn python=3.8
!conda activate envn
Installing packages and creating environments using Conda

Setting up Google Colab and installing Conda

  1. Go to Google Colab and sign in with your Google account (not required If you are already signed in).

  2. Once we sign in, the window will pop up, and we can choose from the existing notebooks or create a new notebook by clicking the “New notebook” option.

  3. Once the notebook is open, we can see many options, such as renaming our notebook, choosing runtime, selecting hardware, etc.

  4. After setting up the notebook, we can run our code/script in the notebook.

Here is an example to set up and install conda on our Google Colab notebook:

Choose or upload a google colab notebook
Choose or upload a google colab notebook
1 of 4

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved