0

I am using Ubuntu 14.04 and trying to install opencv 3.3.0. While I execute cmake to get the make files, it is not able to locate the Python interpreter, displaying the following message (though the cmake proceeds)

    -- Could NOT find PythonInterp: Found unsuitable version "2.7.6", 
       but required is at least "3.4" (found /usr/bin/python)
    -- Could NOT find PythonInterp: Found unsuitable version "2.7.6", 
       but required is at least "3.2" (found /usr/bin/python)

When I check /usr/bin/ , I could see python libraries/binaries present there (found in the image below)

enter image description here

I could also see the following versions of python

 python             python2.7-config   python3.4          python3.4m-
 config  python3.5m-config  python3m-config    
 python2            python2-config     python3.4-config   python3.5          
 python3-config     python-config      
 python2.7          python3            python3.4m         python3.5m         
 python3m           python-mkdebian  

How can I solve this? Due to this issue, I am not able to use cv2 in my python script, as it throws the following error

    ImportError: No module named 'cv2'

1 Answers1

-2
/usr/bin/python

is a symlink.

Try

ls -l /usr/bin/python

It's probably pointing to python2.7

You need to do (as root)

ln -f -s /usr/bin/python3.4 /usr/bin/python

This will delete the old symlink (because of the -f) and make a new one pointing to python3.4.

Unfortunately there are some incompatibilities between python version 2 and python version 3, so the above instructions may break some other applications. If you see that problem, you might try upgrading your version of cmake. cmake seems to look for a python interpreter using a list in the file

/usr/share/cmake-<version>/Modules/FindPythonInterp.cmake

If you have an older version of this file which contains a line like

set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0)

you could try editing it to

set(_PYTHON3_VERSIONS 3.4 3.3 3.2 3.1 3.0)

I haven't tried this myself as I have a newer version of cmake, but it should be worth a try.

rparkins
  • 19
  • 1
  • 4