I can activate my env in my shell
> conda activate env
When I'm in a bash script, I can check the version of my conda but I can't activate my env
#!/bin/bash
conda --version
> conda 4.7.12
conda activate 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'.
Here is my .bashrc
about conda initialization
8 # User specific aliases and functions
9
10 # >>> conda initialize >>>
11 # !! Contents within this block are managed by 'conda init' !!
12 __conda_setup="$('/work/***/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
13 if [ $? -eq 0 ]; then
14 eval "$__conda_setup"
15 else
16 if [ -f "/work/***/miniconda3/etc/profile.d/conda.sh" ]; then
17 . "/work/***/miniconda3/etc/profile.d/conda.sh"
18 else
19 export PATH="/work/***/miniconda3/bin:$PATH"
20 fi
21 fi
22 unset __conda_setup
23 # <<< conda initialize <<<
I found from here : Conda command working in command prompt but not in bash script that I can add in my bash script before activate my env :
source /work/***/miniconda3/etc/profile.d/conda.sh
And it works (my env is activated) but I don't want to add this line at the begginning of all my bash scripts since I already have it in my .bashrc
. I also found from here : Python - Activate conda env through shell script that I can source my .bashrc
when I run my script with
bash -i shell_script.sh
It is also working (my env is activated).
How can I source automatically my .bashrc
each time I run a script without adding a line in each script and without adding -i
? Can I do this with my .bashrc_profile
for example ?