I have a desktop shortcut that has the following Exec line:
Exec=conda activate my_env && my_command
However, this shortcut doesn't launch. To try to debug this, I ran the same command in a bash prompt without .bashrc (since .bashrc doesn't get sourced for desktop shortcuts),
user@pc:~$ bash --norc
bash-4.4$ conda activate my_env
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'.
The problem is that conda doesn't detect that it has been initialised already. conda init creates an entry in .bashrc:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/user/anaconda/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/user/anaconda/etc/profile.d/conda.sh" ]; then
. "/home/user/anaconda/etc/profile.d/conda.sh"
else
export PATH="/home/user/anaconda/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
I tried to copy this entry to my .profile and relogged in, but it still didn't work. Trying to instead conda init inside .profile just duplicates the above entry in .bashrc.
Is it possible to activate a conda environment from a linux desktop shortcut?