Install Conda and friends on Google Colab, easily
Project description
condacolab
Install Conda and friends on Google Colab, easily.
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_anaconda()
: This will install the Anaconda 2020.02 distribution, the last version that was built for Python 3.7. This contains plenty of data science packages, but they might be outdated by now.install_miniconda()
: This will install the Miniconda 4.9.2 distribution, using a version built for Python 3.7. Unlike Anaconda, this distribution only containspython
andconda
.install_miniforge()
: Like Miniconda, but built offconda-forge
packages. The Miniforge distribution is officially provided by conda-forge but I forked and patched it so it's built for Python 3.7.install_mambaforge()
: Like Miniforge, but withmamba
included. The Mambaforge distribution is officially provided by conda-forge but I forked and patched it so it's built for Python 3.7.
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.7 distribution that fulfills your own needs.
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
How does it work
Google Colab runs on Python 3.7. 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.7 (conda
auto updates by default) 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.
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 withconda create
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file condacolab-0.1.2.tar.gz
.
File metadata
- Download URL: condacolab-0.1.2.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.7.6 Linux/4.19.128-microsoft-standard
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 285a468307a5c8d910cc6aa04a820535908bf5f728f4eb88cf203a5dea8b4650 |
|
MD5 | c29142657e5420e1688a160f17cf0ce6 |
|
BLAKE2b-256 | 2c6327f66d5f08a394d01911a74aafbdfaa500f22e9aa86ec5b9dfa6e69d3a13 |
File details
Details for the file condacolab-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: condacolab-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.7.6 Linux/4.19.128-microsoft-standard
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97db809d3c4bf9c8eb87e6218ceec62a6f1516fd11fdcca255379d27b71d3b19 |
|
MD5 | 0f81d7801dcc0c0678e16d171ca5d76c |
|
BLAKE2b-256 | ee476f9fe13087c31aba889c4b09f9beaa558bf216bf9108c9ccef44e6c9dcfe |