Skip to content Skip to sidebar Skip to footer

Running Conda Environments In Google Colab

Is it possible to run conda environments in google colab? I successfully installed conda and created an environment. But I get an error when trying to run the environment.

Solution 1:

To run conda environments within google colab, you can use a %%bash magic line. Then you would have to run python again and execute your python commands. See below for example.

Example:

# activate your conda environment
%%bash
source activate myenv
python

# python commands are ready to run within your environment
import sys
print("Python version")
print (sys.version)
  • 1st line opens a "semi-permanent" bash shell
  • 2nd line activates your local environment
  • 3rd line goes back to a python executable
  • 4th line onwards are normal python commands

Post a Comment for "Running Conda Environments In Google Colab"