Search code examples
pythonopencvjupyter-notebook

cv2 import error on Jupyter notebook


I'm trying to import cv2 on Jupyter notebook but I get this error:

ImportError: No module named cv2

I am frustrated because I'm working on this simple issue for hours now. it works on Pycharm but not on Jupiter notebook. I've already installed cv2 into Python2.7's site packages, configured Jupyter's kernel to python2, browsed the documentation but I still don't get what I am missing ?

(I'm using windows 10 and working with microsoft cognitives api, that's why I need to import this package.)

here is the code:

 <ipython-input-1-9dee6ed62d2d> in <module>()
----> 1 import cv2
      2 cv2.__version__

What should I do in order to make this work ?


Solution

  • 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. You can follow the instructions here.