3

I was trying to activate an environment by !conda activate <environment name> in Google Colab, but it returned error:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run
$ conda init <SHELL_NAME>
...

so I ran !conda init bash and restarted the kernel to initialise bash. But when I tried !conda activate again, it returns /bin/bash: conda: command not found. It seems like all of my environment and conda disappeared in the content folder. How should I change the shell setting back or activate a new environment under such situation?

Thank you!

Henryhu
  • 31
  • 1
  • 2

1 Answers1

-1

Verify if conda is already installed

I ran into the same issue. Generally, to check if you have conda already installed run the following first:

!conda --version
!which conda

Install conda

If you don't have conda installed, you can unblock yourself by running the following piece of code first:

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

Note, once the above piece of code has successful run, the kernel should have rebooted itself, and you should be good to go. To verify that conda has been successfully installed run the !conda --version command again.

References:

  1. https://inside-machinelearning.com/en/how-to-install-use-conda-on-google-colab/
user3613932
  • 1,219
  • 15
  • 16
  • Doing this is actually not useful since you cannot use `conda create`, thus defeating the purposes. – RanWang May 08 '23 at 02:24