Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named 'cv2' using jupyter

I am trying to import OpenCV into my ipynb using Jupyter. I kept getting :

ImportError: No module named 'cv2'

import cv2
import pandas as pd
import numpy as np
import matplotlib

from matplotlib import pyplot as plt
import seaborn as sns

Any idea how to import cv2 in jupyter?

like image 964
jj pan Avatar asked Sep 25 '15 08:09

jj pan


2 Answers

If you have already installed opencv, then its possible that your notebook and your opencv library are in 2 different python environments. The following has helped me in the past:

  1. Open your notebook
  2. In an new cell type:

!pip install opencv-python

Note, that the ! is deliberate. This will install open-cv in your current notebook environment.

like image 103
alif Avatar answered Nov 06 '22 17:11

alif


You can type

which jupyter-notebook

if it's not in the envs of opencv-python installed, you should install jupyter in the envs:

condda install jupyter-notebook
like image 24
neurobot Avatar answered Nov 06 '22 18:11

neurobot