2019.12.15(pm): Virtual Environment Management with Anaconda

If you are using anaconda, you will see that the command is set to base and root. Virtual environment management is essential and important when using Python. Today, let’s look at how to create and manage virtual environments in Anaconda.

Here are the commands:

// identify conda version
conda --version 

// conda version update
conda update -n base -c defaults conda

// information about virtual environment in conda
conda info --envs

// create virtual environment
conda create --name YOUR_ENV_NAME python=VERSION

// activate virtual environment 
activate YOUR_ENV_NAME

// deactivate virtual environment
deactivate

// remove virtual environment
conda remove --name YOUR_ENV_NAME --all

To check your Python version, use the bleow command to check your version of Python. This will bring up a version of Python that is installed as of the following, up to python3.8.0.

// identify python version
conda search python

The new virtual environment is named py37 and the version is 3.7.4. That’s because you may have compatibility issues if you install the latest version.

When you search the installed virtual environment, you can see that py37 is newly created as shown below. After activating it, install numpy, matplotlib, and tensorflow.

pip isntall numpy
pip install matplotlib
conda install tensorflow

numpy and matplotlib used the pip command and tensorflow used the conda command. What’s the difference between pip and conda?

pip is a package management tool. Used to install modules or manage dependencies between modules.

Conda, on the other hand, is a tool that provides a virtual environment, such as virtualenv. In other words, you use conda to create a separate virtual environment (isolated) and install packages using pip in that isolated space. (Of course, conda can also install packages managed by anaconda.org)

In the case of conda, it feels like virtualenv + pip, but with the limitation that the packages you can install are limited to packages managed by anaconda.org.

Then look at the list of installed libraries. You can see that it is installed well.