Ask Your Question
0

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

asked 2016-05-31 21:46:31 -0500

Kelvin gravatar image

updated 2016-06-01 11:29:49 -0500

berak gravatar image

I'm trying to build opencv with opencv_contrib on OS X. I will explain step-by-step what I did:

  1. I downloaded the OpenCV 3.1 from: http://opencv.org/downloads.html
  2. I also downloaded the opencv_contribfrom: https://github.com/Itseez/opencv_contrib
  3. I put the opencv_contrib folder inside the opencv-3.1.0 folder
  4. I created a folder called "build" inside the opencv-3.1.0 folder
  5. From the terminal I went to the build folder: /Users/kelvinsp/Downloads/opencv-3.1.0/build/
  6. Then I ran the following commands:

    cmake -DOPENCV_EXTRA_MODULES_PATH=/Users/kelvinsp/Downloads/opencv-3.1.0/opencv_contrib/modules /Users/kelvinsp/Downloads/opencv-3.1.0/

    make -j5

    sudo make install

  7. Then, in the python terminal I tried to run the command: import cv2 and receive the following error: ImportError: No module named cv2

  8. Searching in stackoverflow, I found a solution and I ran the command: export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH
  9. Now the import cv2 command is working, but when I ran the command help(cv2.face) I got the following error: AttributeError: 'module' object has no attribute 'face'

Can someone help me please? I don't know what I'm doing wrong.


cmake output:

-- The CXX compiler identification is AppleClang 7.3.0.7030031
-- The C compiler identification is AppleClang 7.3.0.7030031
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test HAVE_CXX_FSIGNED_CHAR
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Success
-- Performing Test HAVE_C_FSIGNED_CHAR
-- Performing Test HAVE_C_FSIGNED_CHAR - Success
-- Performing Test HAVE_CXX_W
-- Performing Test HAVE_CXX_W - Success
-- Performing Test HAVE_C_W
-- Performing Test HAVE_C_W - Success
-- Performing Test HAVE_CXX_WALL
-- Performing Test HAVE_CXX_WALL - Failed
-- Performing Test HAVE_C_WALL
-- Performing Test HAVE_C_WALL - Failed
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE
-- Performing Test HAVE_CXX_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_C_WERROR_RETURN_TYPE
-- Performing Test HAVE_C_WERROR_RETURN_TYPE - Success
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR - Success
-- Performing Test HAVE_CXX_WERROR_ADDRESS
-- Performing Test HAVE_CXX_WERROR_ADDRESS - Success
-- Performing Test HAVE_C_WERROR_ADDRESS
-- Performing Test HAVE_C_WERROR_ADDRESS - Success
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT
-- Performing Test HAVE_C_WERROR_SEQUENCE_POINT - Success
-- Performing Test HAVE_CXX_WFORMAT
-- Performing Test HAVE_CXX_WFORMAT - Success
-- Performing Test HAVE_C_WFORMAT
-- Performing Test HAVE_C_WFORMAT - Success
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY
-- Performing Test HAVE_C_WERROR_FORMAT_SECURITY - Success
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_C_WMISSING_DECLARATIONS
-- Performing Test HAVE_C_WMISSING_DECLARATIONS - Success
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Success
-- Performing Test HAVE_C_WMISSING_PROTOTYPES
-- Performing Test HAVE_C_WMISSING_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Success
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Success
-- Performing Test HAVE_CXX_WUNDEF
-- Performing Test HAVE_CXX_WUNDEF - Success
-- Performing Test HAVE_C_WUNDEF
-- Performing ...
(more)
edit retag flag offensive close merge delete

Comments

1

can you show us the cmake output ? (append it to your question)

berak gravatar imageberak ( 2016-05-31 23:27:49 -0500 )edit
1

3.:I put the opencv_contrib folder inside the opencv-3.1.0 folder

rather put it next to your opencv-3.1.0 folder

berak gravatar imageberak ( 2016-05-31 23:56:39 -0500 )edit

Thanks @berak.

I rebuild the opencv with the opencv_contrib folder next to the opencv folder (not inside), but still not working.

I updated the question with the cmake output link.

Yesterday I also tried to use the following cmake command to build:

cmake -D OPENCV_EXTRA_MODULES_PATH=/Users/kelvinsp/Downloads/opencv-3.1.0/opencv_contrib/modules -D BUILD_SHARED_LIBS=OFF -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_PYTHON_SUPPORT=ON -D CMAKE_INSTALL_PREFIX=/usr/local ..

but it didn't work.

Kelvin gravatar imageKelvin ( 2016-06-01 09:24:45 -0500 )edit

"but it didn't work." -- please never say that again.

  • where's the cmake output ? please append that to your question
  • can you use any other modules from opencv_contrib ?
berak gravatar imageberak ( 2016-06-01 09:49:55 -0500 )edit

Sorry for ask that, but why never say "but it didn't work."? My english is not so good, but in portuguese it's normal to say that. In my mind, it means that I built everything with this command but I got the same error message.

  • The output log is too large, then I put it on my dropbox and shared the link in the question.
  • I think not, I tried the commands: help(cv2.fuzzy) help(cv2.plot) help(cv2.text) and got the same error: AttributeError: 'module' object has no attribute '...'
Kelvin gravatar imageKelvin ( 2016-06-01 10:08:34 -0500 )edit

apologies, never meant to offend you in any way, - usually, it sounds more like whining, but please let's drop the whole thing.

ando, not a dropbox or any external thing, please really just edit your question again, and append the cmake output there. very likely we'll find some explanation in there !

berak gravatar imageberak ( 2016-06-01 10:49:36 -0500 )edit

also, did you have a previous cv2.pyd installed ? cv2.__version__ would tell, if you're using the right one.

berak gravatar imageberak ( 2016-06-01 10:52:02 -0500 )edit

No problem, you don't offended me, I just wanted to understand to not do it again, but ok I understood your point.

I put the entire cmake output in the question.

I ran the command c2.__version__ and I got this output '3.0.0'. Apparently I have an older version in somewhere.

Kelvin gravatar imageKelvin ( 2016-06-01 11:23:28 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-01 11:37:19 -0500

berak gravatar image

there's a couple of interesting parts in the cmake output:

-- Found PythonInterp: /opt/local/bin/python2.7 (found suitable version "2.7.11", minimum required is "2.7")
-- Could NOT find PythonLibs: Found unsuitable version "2.7.10", but required is exact version "2.7.11" (found /usr/lib/libpython2.7.dylib)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named numpy.distutils
-- Could NOT find PythonInterp: Found unsuitable version "2.7.10", but required is at least "3.4" (found /usr/bin/python)
-- Could NOT find PythonInterp: Found unsuitable version "2.7.10", but required is at least "3.2" (found /usr/bin/python)


--     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python2 python3 viz cvv hdf matlab sfm

in other words, it found python2.7, but no python lib to link to, and no headers, and it did not build a new cv2.pyd at all (so, you don't see any new modules, because you're still running a previous cv2.pyd)

in other words, - try installing python dev packages(no idea for your os), and update numpy to a more recent version, rinse and repeat.

edit flag offensive delete link more

Comments

1

Thank you so much @berak, I will do that.

Kelvin gravatar imageKelvin ( 2016-06-01 12:09:15 -0500 )edit

yea, let's see, what the next iteration gives ..

berak gravatar imageberak ( 2016-06-01 12:10:34 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-05-31 21:46:31 -0500

Seen: 467 times

Last updated: Jun 01 '16