Anaconda activates
I am using anaconda python. So every time, in my mac terminal, I enter the terminal command:
source /Users/mylaptop/anaconda/bin/activate /Users/mylaptop/anaconda
And then I activated the python anaconda environment. But I don't want to write this command line every time, so I tried a bash script like this:
#! /bin/bash
source /Users/mylaptop/anaconda/bin/activate /Users/mylaptop/anaconda
and I put this file in a directory /usr/local/bin
. But unfortunately I cannot enter the anaconda environment this way. There is no error message in the terminal. So I don't know what's going on here.
Can anyone help me?
source to share
The simplest solution is to just put /Users/mylaptop/anaconda
in your PATH by adding something like
export PATH="/Users/mylaptop/anaconda:$PATH"
to your bash ( ~/.profile
) profile .
You cannot put an activated script in a script because it must be the "source" for it to work. source
makes the script run in your current shell (as opposed to the subshell that the bash script is running with). This is necessary because it changes your environment variable PATH
and environment variables from your current shell cannot be changed by sub drills.
source to share