Ask Your Question
0

AttributeError: module 'opencv' has no attribute 'imread' PS C:\Users\OpenCV>

asked 2020-02-02 15:32:48 -0600

Tbot1000 gravatar image

Hello,

I am new to openCV and have started the tutorials online. I'm using Visual Studio Code and Python and get no error when I just import opencv and python. However, when I run these lines of code:'

import opencv as cv
import numpy
img = cv.imread('photo.jpg')

I get this error:

AttributeError: module 'opencv' has no attribute 'imread' PS C:\Users\OpenCV>

I don't understand why this is happening, if I need to specify more I would gladly do so.

Thank you!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-02-02 21:34:18 -0600

supra56 gravatar image

updated 2020-02-02 21:38:04 -0600

You got typo error namespace. Change this:

import opencv as cv

to:

import cv2 as cv
edit flag offensive delete link more

Comments

I changed the name of the folder before. Changing the folder back to cv2 and changing the code, I get the same error.

ModuleNotFoundError: No module named 'cv2
Tbot1000 gravatar imageTbot1000 ( 2020-02-03 07:14:48 -0600 )edit

What is your opencv and python version? You need to pip install opencv-python

supra56 gravatar imagesupra56 ( 2020-02-03 08:54:06 -0600 )edit

Is that 3 lines you do?

import cv2 as cv
import numpy
img = cv.imread('photo.jpg')
supra56 gravatar imagesupra56 ( 2020-02-03 08:59:44 -0600 )edit

For newbie. tutorial

supra56 gravatar imagesupra56 ( 2020-02-03 09:05:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-02-02 15:32:48 -0600

Seen: 12,343 times

Last updated: Feb 02 '20