Reputation: 411
I have a YML file for a Conda environment that runs with Python 3.8.15 (environment.yml
). I am currently trying to load that file into my Google Colab, based on this answer:
conda environment in google colab [google-colaboratory].
!wget -c https://repo.anaconda.com/archive/Anaconda3-2022.10-Windows-x86_64.exe
!chmod +x Anaconda3-2022.10-Windows-x86_64.exe
!bash ./Anaconda3-2022.10-Windows-x86_64.exe -b -f -p /usr/local
And while the executable file for Anaconda was installed in my Google Drive folder, when I run the code, it turms out that Colab could not execute that file:
./Anaconda3-2022.10-Windows-x86_64.exe: ./Anaconda3-2022.10-Windows-x86_64.exe: cannot execute binary file
Is there any other method that I could use to install Anaconda to work with it in Google Colab? And furthermore, how should I load my environment.yml
file after getting Anaconda to run in Colab?
Upvotes: 6
Views: 17682
Reputation: 76700
You cannot run a Jupyter notebook (Colab session) with a new Conda environment, but you can use Conda to augment the packages in the existing Python installation. Installation is streamlined with condacolab
. See the condacolab
documentation.
An quick example would go something like:
First Cell
!pip install -q condacolab
import condacolab
condacolab.install() # expect a kernel restart
Second Cell
mamba install [pkg1 pkg2 ...]
# or, if you have a YAML
mamba env update -n base -f env.yaml
In the YAML case, you must match the same version of Python with the Colab version.
Upvotes: 12