CONDA creating virtual environment and common CONDA commands

Conda creates a virtual environment
1, what is a virtual environment
it is a virtualization, independent from computer hacked out of the environment. Commonly speaking, virtual environment is to use virtual machine Docker to independent part of the content, we call this part of independent things “container”, in this container, we can only install the dependent packages we need, each container is isolated from each other, do not affect each other.
2, why want to use a virtual environment
in the actual project development, we usually according to their own requirements to download all sorts of corresponding framework library, such as Scrapy, Beautiful Soup, etc., but may each project USES the framework of library is not the same, or using a framework version is different, so we need to according to the demand constantly update, or uninstall the corresponding libraries. Working directly with our Python environment can cause a lot of unnecessary hassle for our development environment and project, and can be quite confusing to manage. Like the following scene:
Scenario 1: Project A requires version 1.0 of A framework, and project B requires version 2.0 of the library. If the virtual environment is not installed, then when you use the two projects, you will have to uninstall back and forth, which can easily cause errors in your project.
Scenario 2: Your company’s previous projects need to run in Python 2.7, and your project needs to run in Python 3. If you do not use the virtual environment, you may not be able to use both projects at the same time. If you use Python 3, your company’s previous projects may not be able to run, and your new projects may have trouble running. If the virtual environment can configure different runtimes for the two projects, then both projects can run at the same time.
Second, conda common commands
in the Anaconda conda can be understood as a tool, is also an executable commands, its core function is package management and environmental management. Therefore, the virtual environment to create, delete and other operations need to use the conda command.
1. Create a virtual environment

conda create-n env_name numpy matplotlib python=2.7 # Conda create -n env_name numpy matplotlib python=2.7 #
2. Activate the virtual environment
Linux: source activate your_env_name
Windows: activate your_env_name
tivate root
p>n –version Check if the current Python version is the one you want.
3. Exit the virtual environment
Linux: Conda deactivate your_env_name
Windows: deactivate env_name
4. Remove the virtual environment
Conda remove-n your_env_name(virtual environment name) — ALL
Delete packages from virtual environment:
Conda remove –name $your_env_name $package_name
6. Share the environment
conda env export > environment.yml
7. Create the environment from the YML file
conda env create -f environment.yml
Conda install package_name
(4). Conda install package_name
(4). Conda install package_name
(4). Conda install package_name
(4).
(5). Conda update conda: Check to update the current conda.
(5)

Read More: