You can think of an environment as a quarantined area for development. Often times, you need to install different packages for certain projects. But these packages can sometimes break other ones you need for other projects. Some packages require older versions of other projects and some may require that another package not exist at all. It happens. If you want to share your work with a colleague or collaborate with them, you obviously have two different machines with different setups. You want to avoid the infamous “it works on my machine”. Having this quarantined area can help a lot. Also, if you **** anything up, it won’t damage anything else on your machine. You can just delete the environment and start again.
conda create --name myenv
#Activate environment and install how you would normally
conda activate myenv
conda install package
#Install while environment is not activated
conda install --name myenv package
#Deactivate Environment
conda deactivate
#See a list of packages installed in an environment
conda list -n myenv
#Remove package
conda remove -n myenv package
#List all existing environments
conda env list
#Remove environments
conda remove --name myenv --all
In order for your environment to show up as a kernel option in Jupyter Lab or Notebook, you will have to install nb_conda_kernels. I have had problems with this working in the past. Using the following commands, however, has always worked for me.
source activate myenv
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
I recommend you look at the official page on managing environments in Anaconda and the official page on managing packages. There are many more tricks you can use, including making and exporting YML files to share environments or, for that matter, import a YML file to recreate an environment. You can also very specifically determine which version of a package or Python to use.