The purpose of creating a virtual environment is to allow the project to run in an independent local Python environment, so that projects in different environments do not interfere with each other.
At present, I use the virtual environment only to switch between python2 and python3. Go deeper, you can use it later.
1 View the virtual environment
You can enter the following command to see how many virtual environments have been installed in the current system.
conda env list
My result is
# conda environments:
#
base /home/my_name/anaconda3
cvxpy * /home/my_name/anaconda3/envs/cvxpy
python27 /home/my_name/anaconda3/envs/python27
2 Basic operation
2.1 Create a new virtual environment
Suppose we want to create a virtual environment called myenv, and install the version of python 3.5, we can enter the following command.
conda create --name myenv python=3.5
2.2 Start and close the virtual environment
activate myenv #启动虚拟环境myenv
deactivate#结束当前虚拟环境
2.3 Delete virtual environment or package
To delete a package in the virtual environment (for example, numpy in the virtual environment myenv just created), you can enter the following command
conda remove --name myenv numpy
If you want to delete the entire virtual environment, you can enter the following command to complete the deletion
conda env remove --name myenv
references: