ScientiaEtVeritas
ScientiaEtVeritas

Reputation: 5278

activating conda fails (sourcing ~/.bashrc)

I freshly installed Anaconda (Anaconda3-2019.07-Linux-x86_64) on "Ubuntu 14.04.5 LTS", but activating the installation fails with:

source ~/.bashrc returns Illegal variable name.

cat ~/.bashrc:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/scientia/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/scientia/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/scientia/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/scientia/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

The first line seems to be the reason for that: __conda_setup="$('/home/scientia/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"

Upvotes: 0

Views: 3249

Answers (3)

MuMengSunny
MuMengSunny

Reputation: 1

First,find your shell through this:

echo $Shell

if you get:csh, you should input:

conda init tcsh

or:./conda init tcsh in ~/anaconda3/bin/

Upvotes: 0

merv
merv

Reputation: 76700

As you've found, the .bashrc initialization is bash-specific. However, Conda does also support initialization for csh/tcsh. Simply run

/home/scientia/anaconda3/bin/conda init tcsh

then restart your tcsh session and now Conda should be properly configured. You can run the above with a verbose flag -v if you want to see what it adds to .tcshrc.

Upvotes: 4

ScientiaEtVeritas
ScientiaEtVeritas

Reputation: 5278

I found that I was using the tcsh shell, which doesn't allow syntax like that used in .bashrc.

Executing bash and then sourcing has worked.

Upvotes: -1

Related Questions