简体   繁体   中英

AttributeError: module 'cv2.cv2' has no attribute 'DataFrame'

So after having a lot of trouble with importing cv2 , I now have this error showing up:

Traceback (most recent call last):
  File "/home/test/Projet/IDO/ido-security-cam/code.py", line 19, in <module>
    dataFrame = cv2.DataFrame(columns = ["start","end"])
AttributeError: module 'cv2.cv2' has no attribute 'DataFrame'

Yes, I do have the same python version on my interpreter and in vscode (3.7.3). I already installed opencv both versions because I was desperate. Here are the commands I tried :

pip3 install opencv-contrib-python
pip3 install opencv-python

The error shows up knowing that I use other cv2 methods like cv2.VideoCapture() and it doesn't send me back error. I just don't why the DataFrame() method won't work. DataFrame is from the Pandas library which is already installed but not imported. I really don't know what to try next...

Thanks in advance for you help !

I did trust a code that was previously working that's why I didn't see this error.

Dataframe is a function part of the pandas module, so of course it won't work using cv2 . To make it works, you need to use pandas.DataFrame()

Thanks again !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM