How do I Install Python Packages in Anaconda?


One of the most popular ways to manage and distribute Python packages is through the Anaconda distribution, which is a free and open-source distribution of Python.

Installing Python packages in Anaconda is a simple process that can be done through various methods, such as using the conda command, pip, or the Anaconda Navigator.

In this guide, we will explore the different methods for installing Python packages in Anaconda and explain how to use each one. Whether you are a beginner or an experienced Python developer, this guide will provide you with the knowledge you need to effectively manage and distribute your Python packages in Anaconda.

Method 1: Anaconda Navigator

To add Python packages to an Anaconda environment using the Navigator follow the below steps,

  • Open Anaconda Navigator and select the "Environments" tab.

  • Select the environment to which you want to add the packages. If you want to create a new environment, you can click on the "Create" button.

  • Click on the "Not Installed" tab. This will show a list of all the packages that are not currently installed in the selected environment.

  • Search for the package(s) you want to install by typing the package name in the search bar.

  • Select the package(s) you want to install by clicking on the checkbox next to the package name.

  • Click the "Apply" button to begin installing the package(s).

  • You will be prompted to confirm the installation. Click "Apply" again to confirm the installation.

  • The package(s) will be installed and will appear in the "Installed" tab of the selected environment.

Method 2: Conda Command

To add Python packages to an Anaconda environment using the terminal or an Anaconda Prompt, you can use the conda command.

  • Open the terminal or the Anaconda Prompt.

  • Activate the environment to which you want to add the package(s) by using the command −

conda activate myenv
  • Use the conda install command to install the package(s) you want to add to the environment. For example, to install the numpy package, you would use the following command −

conda install numpy
  • You can also install multiple packages at once by listing them separated by spaces.

conda install numpy pandas matplotlib
  • Press enter to start the installation process. You will be prompted to confirm the installation. Press y to confirm and continue with the installation.

  • Once the installation is complete, you can verify that the package(s) have been added to the environment by using the below command.

conda list

Method 3: Pip Command

To add packages to an Anaconda environment using the pip command, you can use the pip command within the activated conda environment.

  • Open the terminal or the Anaconda Prompt.

  • Use the pip install command to install the package(s) you want to add to the environment. For example, to install the numpy package, you would use the following command −

pip install numpy
  • You can also install multiple packages at once by listing them separated by spaces.

pip install numpy pandas matplotlib
  • Press enter to start the installation process. The package(s) will be installed and added to the active environment.

Note − you need to have a stable internet connection as packages will be downloaded from the internet. Also, pip is a package manager which is the default in python, while conda is a package, environment, and dependency manager which is available with Anaconda distribution.

To Conclude

Installing Python packages in Anaconda is an important aspect of working with this distribution. With the various methods available, such as using conda, pip, or the Anaconda Navigator, you have the flexibility to choose the method that best suits your needs and level of expertise.

With this knowledge, you should be able to confidently install and manage your Python packages in Anaconda.

Updated on: 28-Aug-2023

31K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements