Skip to main content

condacolab

Downloads Downloads Downloads

Install Conda and friends on Google Colab, easily.

CondaColab

Usage

TLDR: Check the example notebook here!

On your Colab notebook, run the following code as the first executable cell:

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

After the kernel restart, you can optionally add a new cell to check that everything is in place:

import condacolab
condacolab.check()

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.

The default condacolab.install() provides Mambaforge, but there are other conda distributions to choose from:

  • install_miniconda(): This will install the Miniconda distribution, using a version built for Python 3.11. Unlike Anaconda, this distribution only contains python and conda.
  • install_miniforge(): Like Miniconda, but built off conda-forge packages. The Miniforge distribution is officially provided by conda-forge.

For advanced users, install_from_url() is also available. It expects a URL pointing to a constructor-like installer, so you can prebuild a Python 3.11 distribution that fulfills your own needs.

If you want to build your own constructor-based installer, check the FAQ below!

Once the installation is done, you can use conda and/or mamba to install the needed packages:

!conda install openmm

# or, faster:
!mamba install openmm

If you have a environment file (e.g. environment.yml), you can use it like this:

!conda env update -n base -f environment.yml

# or, faster:
!mamba env update -n base -f environment.yml

Shortcomings

  • The Python kernel needs to be restarted for changes to be applied. This happens automatically. If you are wondering why you are seeing a message saying "Your session crashed for an unknown reason", this is why. You can safely ignore this message!
  • You can only use the base environment, so do not try to create more environments with conda create. If you have an environment file, use conda env update -n base -f <your-file.yml>.

FAQ

How does it work?

Google Colab runs on Python 3.11. We install the Miniconda distribution on top of the existing one at /usr/local, add a few configuration files so we stay with Python 3.11 and the newly installed packages are available. Finally, we wrap the Python executable to redirect and inject some environment variables needed to load the new libraries. Since we need to re-read LD_LIBRARY_PATH, a kernel restart is needed.

How can I cache my installation? I don't want to wait every time I start Colab.

The recommended approach is to build your own constructor-based installer. We have provided an example in constructor-example/construct.yaml.

You can generate a constructor installer on Colab too! Follow this tutorial.

Locally, follow these steps:

  1. In your local computer:
conda create -n constructor -c conda-forge constructor
conda activate constructor
mkdir my-installer
cd my-installer
curl -sLO https://raw.githubusercontent.com/jaimergp/condacolab/main/constructor-example/construct.yaml
curl -sLO https://raw.githubusercontent.com/jaimergp/condacolab/main/constructor-example/pip-dependencies.sh
  1. Add your conda packages to construct.yaml in the specs section. Read the comments to respect the constrains already present! You can also adapt the metadata to your liking.
  2. If you do need to install pip requirements, uncomment the post_install line and edit pip-dependencies.sh.
  3. Run constructor --platform linux-64 .
  4. Upload the resulting .sh to an online location with a permanent URL. GitHub Releases is great for this!
  5. In Colab, run:
!pip install -q condacolab
import condacolab
condacolab.install_from_url(URL_TO_YOUR_CUSTOM_CONSTRUCTOR_INSTALLER)

Can I install R packages?

Yes, as long as you make sure you also install rpy2 to overwrite Colab's installation. See issue #26 for more details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

condacolab-0.1.11.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

condacolab-0.1.11-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file condacolab-0.1.11.tar.gz.

File metadata

  • Download URL: condacolab-0.1.11.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Darwin/25.5.0

File hashes

Hashes for condacolab-0.1.11.tar.gz
Algorithm Hash digest
SHA256 13f2c080f4292a1d87d06f150e8bad62c5d73a3dcd813fc01ab6a99ebf4f2a00
MD5 752623281a297cd6f1d3f7c9d1ea575d
BLAKE2b-256 309f90a55e65960b7c27240e724c96170138ab4a9fb450cf8819cc054686998c

See more details on using hashes here.

File details

Details for the file condacolab-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: condacolab-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Darwin/25.5.0

File hashes

Hashes for condacolab-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 0f3afa89992996aba067bd5c1f087c8aebbc3f14b089374a675da524840a9775
MD5 82726da8d0716501695fa5d47c191c44
BLAKE2b-256 76bcca32c6720a7cb6609ad807cd10aa00a514abe547286090487a09ab1f8be6

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.13

2 files

0.1.12

2 files

This release

0.1.11 This release

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page