0

hope you are doing good. I have been working on a project and I have this warning. So, please help me with this.

import os
import cv2
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

img = cv2.imread('img1.jpeg')
plt.imshow(img)

this is the code

ti7
  • 16,375
  • 6
  • 40
  • 68
Cts
  • 19
  • 1
  • 2
  • you might have named a directory in your project `cv2` (so it's trying to read from that, rather than the real `cv2` import) – ti7 Oct 23 '22 at 15:59
  • message vs code does not make sense. more details needed. – LhasaDad Oct 23 '22 at 16:06
  • 2
    If you have Pycharm IDE - https://stackoverflow.com/questions/60229392/python-3-opencv-set-up-problem-cannot-find-reference-videocapture-in-init – Сергей Кох Oct 23 '22 at 16:11
  • Can you show a complete stack trace please? Important information will be found in there to solve the problem. – joanis Oct 23 '22 at 16:22
  • Also, there appear to be multiple packages providing `cv2`. Can you show how you installed it? Make sure you are installing the version whose documentation you are using! – joanis Oct 23 '22 at 16:25
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 23 '22 at 16:29

1 Answers1

0

The code works fine on my system, the most likely explanation is a clash between the library and a cv2 folder in the same directory as the script you are running it in. Whenever you import a module in Python, the first place it looks for the module is in the folder the script is running in. Also try updating the module via the command pip install opencv-python --upgrade.

splewdge
  • 3
  • 3