The team at Anaconda seem to assume that you are only ever going to use your machine to develop Python software, so it’s quite opinionated and the default install does a number of things that you might not be happy with if you use your machine for other purposes.
I get that for most people starting out, this keeps things simple, but I’d prefer to integrate Anaconda and Python into my environment at will rather than have it stomp all over everything else, all of the time.
Luckily, there are a few hacks that allow you to do this.
A Separate Shell For Anaconda
The first thing that I noticed was that Anaconda adds some setup at the bottom of your logon script (in my case, .zshrc). This initialises the Anaconda command line and prefixes the command prompt with the name of your current Anaconda environment.
That’s great if you’re in Python programming mode, but not what I want if I’m doing anything else from the command prompt. I experimented a little, and I worked out that it was quite happy if I moved the setup script from .zshrc to another file (anaconda3/init.zsh). I then created a duplicate terminal profile in iTerm that ran that script at startup thus:
source ~/anaconda3/init.zsh
Store Environments Where I Want Them To Be
By default when you create an environment thus
conda create --name myenvironment
Anaconda will place that environment folder in ~/anaconda3/envs. Whilst that’s tidy if you’re just starting out, it’s not ideal in all cases.
The first hack that I tried was this
cd ~/my/chosen/directory
conda create --prefix ./myenvironment
That worked, but you can’t assign a nice, convenient name to your environment at the same time.
Reading around, I discovered that you can set an environment variable that tells Anaconda where to put environments by default.
export CONDA_ENVS_PATH="~/my/chosen/directory"
I added that to the top of my init.zsh script and now when I create by name, it puts the environment where I want it to be.