How to Install OpenCV in Anaconda

OpenCV is a tool used for image processing and computer vision.  Python is the most popular programming language that is supported by OpenCV because it is simple to use.  Anaconda contains a variety of Python packages that are used in data science and machine learning.  There are a variety of ways to install OpenCV in Anaconda for Windows, Mac, and Linux.  This minHour article teaches you how to install OpenCV in Anaconda.

Using the Anaconda Navigator

Install Python if it’s not already installed.

Python is the programming language Anaconda was written for. If you have not already done so, be sure to install Python. You can download the latest Python installer for Windows, Mac, or Linux at https://www.python.org/downloads/. Download the Python install and open the installation file. Then follow the instructions to complete the installation.

Install Anaconda.

The Individual Edition of Anaconda is open-source and free to download for all platforms. If you want the Commercial or Enterprise edition, you will need to purchase a license. Use the following steps to download and install the Individual Edition of Anaconda:

  • Visit https://www.anaconda.com/products/individual using a web browser.
  • Click the icon for the operating system you are using below “Get additional Installers”.
  • Click the download link that is appropriate for your operating system.
  • Open the installation file in your Downloads folder or web browser.
  • Follow the instructions to complete the installation.
  • Select “Only Me” when asked if you want to install Anaconda for you or for all users on your computer.

Open the Anaconda Navigator.

The Anaconda Navigator app has an icon that resembles a green circle that is dissolving on the right side. You can find the Anaconda Navigator in the Windows Start menu on Windows, or in the Applications folder on Mac. Use one of the following steps to open the Anaconda Navigator:

  • Windows: Click the Windows Start menu and type “Anaconda Navigator.” Click the Anaconda Navigator icon.
  • Mac: Click the magnifying glass icon in the upper-right corner of the menu bar at the top. Type “Anaconda Navigator” in the Spotlight search bar. Click the Anaconda Navigator app icon.

Click Environments.

It’s in the menu panel to the left of the Anaconda Navigator app.

Use the drop-down menu to select “Not Installed.”

The drop-down menu is at the top of the list of environments in the Anaconda Navigator.

Type opencv in the packages search box.

Use the search box in the upper-right corner of Anaconda Navigator that says “Search Package,” not the one to the left that says “Search Environments.”

Click the checkbox next to “OpenCV.”

It should be the second option in the list. This places an arrow icon in the checkbox.

Click Apply.

It’s in the lower-right corner of the Anaconda Navigator. This displays a prompt informing you that it is “solving environment.” This may take a while, depending on your internet connection.

Click Apply.

This installs OpenCV in Anaconda.

Using the Anaconda Prompt in Windows

Install Python if it’s not already installed.

Python is the programming language Anaconda was written for. If you have not already done so, be sure to install Python. You can download the latest Python installer for Windows, Mac, or Linux at https://www.python.org/downloads/. Download the Python install and open the installation file. Then follow the instructions to complete the installation.

Install Anaconda.

The Individual Edition of Anaconda is open-source and free to download for all platforms. If you want the Commercial or Enterprise edition, you will need to purchase a license. Use the following steps to download and install the Individual Edition or Anaconda:

  • Visit https://www.anaconda.com/products/individual using a web browser.
  • Click the icon for the operating system you are using below “Get additional Installers”.
  • Click the download link that is appropriate for your operating system.
  • Open the installation file in your Downloads folder or web browser.
  • Follow the instructions to complete the installation.
  • Select “Only Me” when asked if you want to install Anaconda for you or for all users on your computer.

Open the Anaconda Prompt.

The Adaconda Prompt is a Command Prompt environment that is only available for Windows. Use the following steps to open the Anaconda Prompt.

  • Click the Windows Start menu.
  • Type “Anaconda.”
  • Click the Anaconda Prompt icon.

Type conda update –all and press ↵ Enter.

This checks for updates to Anaconda and updates you to the latest version of Anaconda.

Create a new environment (optional).

If you want to install OpenCV in a separate environment, you will need to create it first. Use the following steps to create a new environment:

  • Type conda create –name [environment_name]. Replace “[environment_name]” with the name of the environment you want to create.
  • Press Enter.
  • Type activate [environment_name] and press Enter.

Type conda install -c menpo opencv and press ↵ Enter.

The “conda” command connects to the Anaconda software repository. You can use this command to install Anaconda packages. This command installs OpenCV in your Anaconda environment.

  • Alternatively, you can enter conda install -c conda-forge opencv and press Enter.
  • If you are not able to install OpenCV, it may be that you are using the wrong version of Python or you may need to update Anaconda.

Press y when prompted and press ↵ Enter.

This completes the installation.

Using PIP

Install Python if it’s not already installed.

Python is the programming language Anaconda was written for. If you have not already done so, be sure to install Python. You can download the latest Python installer for Windows, Mac, or Linux at https://www.python.org/downloads/. Download the Python install and open the installation file. Then follow the instructions to complete the installation.

Install Anaconda.

The Individual Edition of Anaconda is open-source and free to download for all platforms. If you want the Commercial or Enterprise edition, you will need to purchase a license. Use the following steps to download and install the Individual Edition of Anaconda:

  • Visit https://www.anaconda.com/products/individual using a web browser.
  • Click the icon for the operating system you are using below “Get additional Installers”.
  • Click the download link that is appropriate for your operating system.
  • Open the installation file in your Downloads folder or web browser.
  • Follow the instructions to complete the installation.
  • Select “Only Me” when asked if you want to install Anaconda for you or for all users on your computer.

Open the Command Prompt or Terminal on your computer.

It typically has an icon that resembles a black screen with a white cursor. Use one of the following steps to open the Command Prompt or Terminal:

  • Windows: Click the Windows Start menu and type “CMD.” Click the Command Prompt icon in the Windows Start menu.
  • Mac: Click the magnifying glass icon in the upper-right corner of the menu bar at the top. Type “Terminal” in the Spotlight search bar. Click the Terminal icon.

Create a new environment (optional).

If you want to install OpenCV in a separate environment, you will need to create it first. Use the following steps to create a new environment:

  • Type conda create –name [environment_name]. Replace “[environment_name]” with the name of the environment you want to create.
  • Press Enter.
  • Type activate [environment_name] and press Enter.

Type pip install opencv-python and press ↵ Enter.

PIP is the Python software package library. This command installs OpenCV using PIP.

Using Linux

Install Python if it is not already installed.

Anaconda is contains a variety of Python packages. If you have not already installed Python, use the following steps to install Python on Linux:

  • Press Ctrl + Alt + T to open the Terminal.
  • Type python3 –version and press Enter to verify if Python is installed.
  • Type sudo apt-get update and press Enter to update your software library.
  • Type sudo apt-get install python to install Python.

Download the Anaconda installation file.

Use the following steps to download the Anaconda installation file:

  • Go to https://www.anaconda.com/products/individual in a web browser.
  • Click the penguin icon below “Get additional installers” to the right.
  • Click 64-Bit (x86) Installer (581 MB) to download the “.sh” file for Anaconda.

Navigate to the Anaconda installation file in the Terminal.

To do so, type cd followed by the path that the installation file downloaded to and press . For example, if the installation file is in your Downloads folders, you would type cd Downloads and press to navigate to the Downloads folder in the Terminal.

Type chmod +x followed by the installation file name and press ↵ Enter.

This grants you permission to execute the installation file.

  • For example, type chmod +x Anaconda3-2021.11-Linux-x86_64.sh to enable the installation file for the 2021 version of Anaconda.

Type the command to execute the installation file.

To do so, type ./ followed by the installation file name and press to execute the installation file.

  • For example type ./Anaconda3-2021.11-Linux-x86_64.sh to execute the installation file for the 2021 version of the Anaconda installation file.

Press y when prompted and press ↵ Enter.

This confirms where you want to install Anaconda and installs Anaconda.

Type conda update –all and press ↵ Enter.

This checks for updates to Anaconda and installs the latest version.

  • When prompted, press Y and press Enter.

Create a new environment (optional).

If you want to install OpenCV in a separate environment, you will need to create it first. Use the following steps to create a new environment:

  • Type conda create –name [environment_name]. Replace “[environment_name]” with the name of the environment you want to create.
  • Press Enter.
  • Type activate [environment_name] and press Enter.

Type pip install opencv-python and press ↵ Enter.

This installs OpenCV using PIP.

Leave a Comment