Install conda packages on Google Colab, easily.
⚠️ Note: This README refers to the development version ofcondacolab. If you are looking for the stable version, please check the0.1.xbranch.
On your Colab notebook, run the following code as the first executable cell:
!pip install -q "https://github.com/conda-incubator/condacolab/archive/main.zip"
import condacolab
condacolab.install()It is important that you perform the installation first thing in the notebook because it will require a kernel restart, thus resetting the variables set up to that point.
This will set up a bare environment with only the essentials to run the Python kernel. If you need
more packages, use the dependencies and/or pypi_dependencies arguments. You can also change
the default Python version.
# Use Python 3.14
condacolab.install(python_version="3.14")
# Install numpy>=2 and scipy
condacolab.install(dependencies={"numpy": ">=2", "scipy": "*"})Yes, check this example notebook for more information.
condacolab or Pixi do no support them directly, but here's a one-liner workaround you can run once condacolab.install() has run:
!pixi exec conda install --file environment.yml --prefix "$CONDA_PREFIX" --yes
The trick is to know that the restarted kernel runs on an activated conda environment, so you can use $CONDA_PREFIX to refer to it. Do note that any other pixi operations on the environment might undo that operation, so make sure to run this workaround as the last step of the setup.
