Conda can realize the reason of multiple environment coexistence

Source: Internet
Author: User
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.








Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.