O.rka
O.rka

Reputation: 30717

How to get base conda installation directory (not CONDA_PREFIX)?

I'm trying to figure out the best way to get the base conda installation directory.

I wrote this but I know this isn't the best way to do it:

(base) -bash-4.2$ which conda
/usr/local/devel/ANNOTATION/jespinoz/anaconda3/bin/conda

(base) -bash-4.2$ which conda | python -c "import sys; print('/'.join(sys.stdin.read().split('/')[:-2]))"
/usr/local/devel/ANNOTATION/jespinoz/anaconda3

Is there some environment variable I'm missing?

Upvotes: 1

Views: 774

Answers (1)

merv
merv

Reputation: 76950

One trick is to echo CONDA_PREFIX from activated base:

conda run -n base bash -c "echo \${CONDA_PREFIX}"

There is also CONDA_ROOT, but I don't think that is defined when no environment is activated.

Upvotes: 3

Related Questions