0

I have an error when running on jupyter notebook

 import cv2 
    import numpy as np
    from matplotlib import pyplot as plt
    %matplotlib inline

And here's the error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_24728/2850105776.py in <module>
----> 1 import cv2
      2 import numpy as np
      3 from matplotlib import pyplot as plt
      4 get_ipython().run_line_magic('matplotlib', 'inline')

ModuleNotFoundError: No module named 'cv2'

May I know how to solve it? Thanks

I was following this tutorial video on creating the project: https://www.youtube.com/watch?v=0-4p_QgrdbE Automatic Number Plate Recognition using Tensorflow and EasyOCR Full Course in 2 Hours | Python

WJLee9559
  • 43
  • 1
  • 6

3 Answers3

0

Make sure you have installed the module and that the version of python you are using is compatible with it. This site might be of help: Cannot find module cv2 when using OpenCV

Finlay
  • 108
  • 10
0

Welcome to SO, just install the package pip install opencv-python or if you are using anaconda conda install -c conda-forge opencv

Felix Filipi
  • 373
  • 2
  • 12
  • Ok, so I have installed before running the codes above but after I had closed the jupyter notebook and reopen, it's unable to identify the cv2 location. – WJLee9559 Nov 28 '21 at 10:17
  • Should I add pip install opencv-python in front of this code in jupyter notebook or cmd? – WJLee9559 Nov 28 '21 at 10:18
  • just add the library in your command prompt, I suggest you to use virtual environment such as anaconda or virtualenvwrapper (if you are using linux), that will solve your problem. – Felix Filipi Nov 29 '21 at 15:04
0

I just a method to solve the problem, which is pip install opencv-contrib-python and now it runs smoothly.

WJLee9559
  • 43
  • 1
  • 6