close

[Solved] cv2 import error on Jupyter notebook

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error cv2 import error on Jupyter notebook in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How cv2 import error on Jupyter notebook Error Occurs?

Today I get the following error cv2 import error on Jupyter notebook in python.

How To Solve cv2 import error on Jupyter notebook Error ?

  1. How To Solve cv2 import error on Jupyter notebook Error ?

    To Solve cv2 import error on Jupyter notebook Error After that, activate the environment that is complaining for the missing cv2 and run the pip install opencv-python command.

  2. cv2 import error on Jupyter notebook

    To Solve cv2 import error on Jupyter notebook Error After that, activate the environment that is complaining for the missing cv2 and run the pip install opencv-python command.

Solution 1

Is your python path looking in the right place? Check where python is looking for the module. Within the notebook try:

import os
os.sys.path

Is the cv2 module located in any of those directories? If not your path is looking in the wrong place. If it is overlooking the install location, append it to your python path.

Solution 2


I didn’t have the openCV installation in my Python3 kernel, so I installed it by activating the specific environment and running this in the command prompt:

pip install opencv-python

How to find and activate my environment?

To list all of Your conda environments, run this command:

conda info --envs

You will get something like this:

ipykernel_py2            D:\Anaconda\envs\ipykernel_py2
root                     D:\Anaconda

After that, activate the environment that is complaining for the missing cv2 and run the pip install opencv-python command.

How to activate an environment?

Just run the command:

activate env_name

where env_name is the wanted environment (for example, You could type activate ipykernel_py2 if You wanted to access the first of the two environments listed above).

Note: If You are on Linux, You need to type source activate env_name.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read