Add packages to Anaconda environment in Python

There are multiple ways by which we can add packages to our existing anaconda environment.

Method 1 − One common approach is to use the “Anaconda Navigator” to add packages to our anaconda environment. Once “Ananconda Navigator” is opened, home page will look something like −

Go to Environments tab just below the Home tab and from there we can check what all packages are installed and what is not.

It is very easy to install any package through anaconda navigator, simply search the required package, select package and click on apply to install it. Let's suppose tensorflow packages are not installed in your computer, I can simply search the required package(like tensorflow), select it and click on apply to install it.

Method 2 − Another way of installing packages is by the use of terminal or an Anaconda Prompt −

conda install opencv

Above command will install OpenCV package into your current environment.

To install specific a specific version of a opencv package −

conda install opencv-3.4.2

We can install multiple packages at once, such as OpenCV and tensorflow −

conda install opencv tensorflow

Note It is recommended to install all required packages at once so that all of the dependencies are installed at once.

To install a specific package such as opencv into your existing environment “myenv”(in case you have a virtual environment to install project specific packages).

conda install –name myenv opencv

Method 3 − If the package is not available in our conda environment or through anaconda navigator, we can find and install the package with another package manager like pip.

We can install pip in our existing conda environment by simply giving the command −

conda install pip

And your screen will be shown an output something like −

Now if you want to install any particular package, through pip in conda environment, we can do it like −

Above we have installed opencv package through pip in conda environment.

Viewing a list of installed packages

We can use the anaconda prompt, to list all of the packages in the active environment −

conda list

Samual Sam
Samual Sam

Learning faster. Every day.