When I activate a Conda environment in a Bash script like:
#!/bin/bash
conda activate ./myenv
which python
python do_stuff.py
The activate line prints out the long warning:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
How do I silence this warning? If I run the conda init bash
command it suggests, that causes Conda to activate my environment by default for all Bash shells, which is definitely not what I want. That's the default configuration in Conda and I explicitly turned that off after it broke functionality everywhere across my system. I want Conda to function similar to virtualenv, where I have a folder containing the environment, and activate it only when needed for a specific application. Under no circumstances do I want a Conda environment activated for every instance of Bash run anywhere on my system.
I'm not sure why it's giving me a CommandNotFoundError, because otherwise Conda populates my Bash shell with the correct paths to Python and other environment-specific resources, and everything else works correctly.