Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up Anaconda so that it doesn't affect other environments like 'homebrew python pip' and Pyenv on MacOS?

It is well known that Anaconda installation on macOS can cause trouble with other widely used package/environment managers like Homebrew, Pyenv, Virtualenv, etc.

The majority of the solutions I've found are 'Anaconda-centric', i.e. using Anaconda as the main python manager and setup conda env for homebrew etc.

However, I am looking for a solution that's kind of 'Homebrew-centric', and setup Anaconda as a compliment. Anaconda should be set up in a way that when ever conda is used, it will work with its own Python, own packages. And leave the rest of system untouched.

The motivation for such solution is because that, for example, when one's main work-flow use homebrew Python3 (python3), homebrew pip (pip3) and Pyenv (pyenv) with requirement.txt. And occasionally using Anaconda when a project is required.

like image 464
zrfrank Avatar asked Feb 24 '19 11:02

zrfrank


1 Answers

Rather than using Anaconda I would suggest using Miniconda, which includes only Python and conda (and a few support packages). Miniconda does not include all of the packages in Anaconda by default, but they can all be installed (with conda install anaconda). Once you download Miniconda, you can install it into your home folder at /Users/username/miniconda3. During the installation, you will be asked if you want to add some initialization code to your .bash_profile. Either choose yes or (if you chose no), then you can run

/Users/username/miniconda3/bin/conda init

to add the conda initialization to your .bash_profile. By default, this will activate the base environment, so you can change the default setting so the environment is not activated by default:

conda config --set auto_activate_base false

You'll probably need to open a new terminal so the conda command is available. Then, when you want to use a conda environment, you can conda activate that environment, but otherwise, conda's Python should not be on your PATH.

like image 118
darthbith Avatar answered Nov 15 '22 12:11

darthbith