Ask Your Question

AttributeError: 'module' object has no attribute 'face'

asked 2016-03-03 10:53:16 -0500

Kelvin gravatar image

Hi, I compiled the opencv with contrib modules in the cmake GUI and everything seems ok, but when I try to use face module (cv2.face) I receive the following message:

AttributeError: 'module' object has no attribute 'face'

Can someone help me please? I lost few days trying to solve that but nothing works.

I'm using Windows 8.1 and Python 2.7


edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2016-03-03 11:00:13 -0500

berak gravatar image

updated 2016-03-03 11:01:08 -0500

the face recognition code is not part of the main opencv repo,

you will need to rebuild opencv together with

please take care to look at the readme there for instructions

then, it was all moved into a new "face" submodule, try a

>>> help(cv2.face)
fr = cv2.face.createLBPFaceRecognizer()
edit flag offensive delete link more


Thanks for the answer. I did it, I rebuild opencv with the extra modules following the tutorial and everything seems to be right, but it still not working. When I run the following command:

import cv2

I'm still getting the error:

AttributeError: 'module' object has no attribute 'face'

Note: I was getting an error when I tried to import cv2 in python:

ImportError: DLL load failed: The specified module could not be found.

Then I copied the cv2.pyd from the opencv directory to the Python27 directory, and it worked fine.

Kelvin gravatar imageKelvin ( 2016-03-03 14:20:36 -0500 )edit

so, it's solved , finally ?

berak gravatar imageberak ( 2016-03-03 14:32:05 -0500 )edit

No, I am still getting the error:

AttributeError: 'module' object has no attribute 'face'

I don't know what to do anymore. :/

Kelvin gravatar imageKelvin ( 2016-03-03 16:45:58 -0500 )edit

try a cv.__version__ (to make sure you're not using ths previous cv2.pyd instead of the new

berak gravatar imageberak ( 2016-03-03 16:57:11 -0500 )edit

Ok. I ran the cv2.__version__ command and got the '3.1.0' version. I think it's the correct version.

Kelvin gravatar imageKelvin ( 2016-03-03 17:10:32 -0500 )edit

I don't know if it means something, but when I run the command:


I get this:




Kelvin gravatar imageKelvin ( 2016-03-03 17:18:33 -0500 )edit

so, this is 3.1, but still your previous one, right ?

  • were there any errors ?
  • did you finally build the INSTALL project (in release mode) ?
  • c:\python27\dlls is the wrong place to put it. please remove cv2.pyd from there. the correct place is c:\python27\Lib\site-packages . (i guess, now you got 2 cv2.pyd, and they get in their way)
berak gravatar imageberak ( 2016-03-03 23:20:59 -0500 )edit

I don't know whats happening, I am very confused about that.

Yes, I did. I clicked the configure button and generate button in the cmake GUI and then run the commands make & make installin the cmd, and everything seems to be right. I have some screen shots in this link:

Ok, I did it, I moved the cv2.pyd from the DLLs folder to the Lib\site-packages folder, but still not working. Sorry, I am very newbie in opencv. Thanks for your help.

Kelvin gravatar imageKelvin ( 2016-03-04 10:10:50 -0500 )edit

Berak, thanks a lot for your help. I gave up using opencv in Windows and started to use it in Ubuntu. In Ubuntu everything is working properly.

Kelvin gravatar imageKelvin ( 2016-03-09 08:50:29 -0500 )edit

answered 2016-03-09 08:47:16 -0500

Kelvin gravatar image

updated 2016-03-09 08:47:54 -0500

I couldn't solve the problem in Windows, then I installed a Virtual Machine (Virtual Box) with Ubuntu and build the opencv and opencv_contrib, and everything worked perfectly.

I know this is not an answer for the problem but it was the only way I could solve the problem.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-03-03 10:51:54 -0500

Seen: 10,893 times

Last updated: Mar 09 '16