I\'m trying to activate my conda env via a bash script. Even though the script runs fine and my PATH appears to be changed within the script, it\'s getting reset somehow aft
I have found the following to work on Mac OSX running a bash shell:
#!/bin/bash
source /Users/yourname/anaconda/bin/activate your_env
python --version # example way to see that your virtual env loaded as expected
Make sure you make the scripted executable with:
chmod +x yourscript.bash
See the link below,
digitalocean-how-to-read-and-set-environmental-and-shell-variables-on-a-linux-vps
below is the snippet from the website,
This is because environmental variables are only passed to child processes. There isn't a built-in way of setting environmental variables of the parent shell. This is good in most cases and prevents programs from affecting the operating environment from which they were called.
On more recent versions of conda (4.6+), I have noticed that the following works:
eval "$(conda shell.bash hook)"
conda activate <env-name>