I had the same problem since yesterday, and I solved it as follows:
- Download OpenCV 3(beta, rc1) and install all the necessary dependencies, including Python dev package.
- Open Cmake GUI.
- Activate the Grouped checkbox.
- Select the OpenCV source and build directories (or just delete the cache if you previously configured).
- Press Configure. Select your preferred generator.
- Check/uncheck the options you need to (OpenGL support, TBB, etc.)
- If you want, you can press Configure after every option modification to see if it fails or not. Just ignore the Python2 options for now.
- Once you have configured all other options, select the PYTHON2 group and delete it with Remove entry.
- Press Configure. The PYTHON2 group will reappear, in red. Do not change anything more, just press Generate.
Now you can make/compile the usual way. The cv2.so file will be created in build/lib/ directory. With make install it will be installed for Python 2.
If it still does not work maybe the problem is somewhere else. After step 8, the cmake output must include the lines (actual paths might be different in your case):
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.6)
Libraries: /usr/lib/i386-linux-gnu/libpython2.7.so (ver 2.7.6)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.2)
packages path: lib/python2.7/dist-packages
In no case there can be a line saying NO, like:
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.6)
Libraries: NO
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.2)
packages path: lib/python2.7/dist-packages
Hope this helps.