Conda can achieve multiple environmental coexistence reasons:
First look at how many environments I currently have:
Conda Info-envs
The results are as follows:
# Conda environments:
#
Python27/users/zj_macbook/anaconda/envs/python27
Python3 */users/zj_macbook/anaconda/envs/python3
Root/users/zj_macbook/anaconda
Activate a different Python environment with the source activate <environment name>
The values for path in the three environments are:
Root
~/anaconda/bin:
/opt/local/bin:
/opt/local/sbin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/library/tex/texbin
Python27:
/users/zj_macbook/anaconda/envs/python27/bin:
~/anaconda/bin:
/opt/local/bin:
/opt/local/sbin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/library/tex/texbin
Python3:
/users/zj_macbook/anaconda/envs/python3/bin:
~/anaconda/bin:
/opt/local/bin:
/opt/local/sbin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/library/tex/texbin
It can be seen from here that Conda writes its current environment to path, so that some of the tools that are invoked at the end are tools in the current environment directory.
For example, there is a corresponding version of the PIP in each of the different Python environments, and when the PIP is used, Pip installs the library file in the Python directory of the current environment.
While brew is different, brew is installed in/usr/local/bin, and Brew installs it in/usr/local/lib/python2.7/site-packages when it invokes the Brew installation library file. In this case, Python in Conda is not a reference to a brew-installed library file.
The Sys.path values for Python in the three environments are:
Root
['',
'/users/zj_macbook/anaconda/lib/python27.zip ',
'/users/zj_macbook/anaconda/lib/python2.7 ',
'/users/zj_macbook/anaconda/lib/python2.7/plat-darwin ',
'/users/zj_macbook/anaconda/lib/python2.7/plat-mac ',
'/users/zj_macbook/anaconda/lib/python2.7/plat-mac/lib-scriptpackages ',
'/users/zj_macbook/anaconda/lib/python2.7/lib-tk ',
'/users/zj_macbook/anaconda/lib/python2.7/lib-old ',
'/users/zj_macbook/anaconda/lib/python2.7/lib-dynload ',
'/users/zj_macbook/anaconda/lib/python2.7/site-packages ',
'/users/zj_macbook/anaconda/lib/python2.7/site-packages/sphinx-1.4.6-py2.7.egg ',
'/users/zj_macbook/anaconda/lib/python2.7/site-packages/aeosa ',
'/users/zj_macbook/anaconda/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg ']
Python27:
['',
'/users/zj_macbook/anaconda/envs/python27/lib/python27.zip ',
'/users/zj_macbook/anaconda/envs/python27/lib/python2.7 ',
'/users/zj_macbook/anaconda/envs/python27/lib/python2.7/plat-darwin ',
'/users/zj_macbook/anaconda/envs/python27/lib/python2.7/plat-mac ',
'/users/zj_macbook/anaconda/envs/python27/lib/python2.7/plat-mac/lib-scriptpackages ',
'/users/zj_macbook/anaconda/envs/python27/lib/python2.7/lib-tk ',
'/users/zj_macbook/anaconda/envs/python27/lib/python2.7/lib-old ',
'/users/zj_macbook/anaconda/envs/python27/lib/python2.7/lib-dynload ',
'/users/zj_macbook/anaconda/envs/python27/lib/python2.7/site-packages ',
'/users/zj_macbook/anaconda/envs/python27/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg ']
Python3:
['',
'/users/zj_macbook/anaconda/envs/python3/lib/python36.zip ',
'/users/zj_macbook/anaconda/envs/python3/lib/python3.6 ',
'/users/zj_macbook/anaconda/envs/python3/lib/python3.6/lib-dynload ',
'/users/zj_macbook/anaconda/envs/python3/lib/python3.6/site-packages ',
'/users/zj_macbook/anaconda/envs/python3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg ']
Here you can see that the path in the Python Sys.path in different environments is the path in the current environment, ensuring that the imported Python package is only in the current environment.