title: OpenCV CMake could NOT find PythonLibs found unsuitable version Ubuntu
body: <p>I am attempting to install OpenCV for Python on Ubuntu 17.10 with Anaconda and Python 3.6.2</p>
  
  <p>My call to CMake is currently:</p>
  
  <pre><code>cmake -D CMAKE_BUILD_TYPE=RELEASE \
  -D CMAKE_INSTALL_PREFIX=/usr/local \
  -D INSTALL_PYTHON_EXAMPLES=ON \
  -D INSTALL_C_EXAMPLES=OFF \
  -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \
  -D PYTHON_EXECUTABLE=~/anaconda3/bin/python \
  -D PYTHON_INCLUDE_DIR=~/anaconda3/include \
  -D PYTHON_LIBRARY=~/anaconda3/lib \
  -D BUILD_EXAMPLES=ON ..\
  </code></pre>
  
  <p>Unfortunately this gives the error:</p>
  
  <pre><code>-- Could NOT find PythonLibs: Found unsuitable version "3.6.3", but required is exact version "3.6.2" (found /usr/lib/x86_64-linux-gnu/libpython3.6m.so)
  </code></pre>
  
  <p>Does anyone have any idea how I might solve this problem?</p>
  
  <p>Edit:</p>
  
  <p>My Anaconda environment contains these packages:</p>
  
  <pre><code>ca-certificates           2017.08.26           h1d4fec5_0  
  certifi                   2017.7.27.1      py36h8b7b77e_0  
  libedit                   3.1                  heed3624_0  
  libffi                    3.2.1                hd88cf55_4  
  libgcc-ng                 7.2.0                h7cc24e2_2  
  libstdcxx-ng              7.2.0                h7a57d05_2  
  ncurses                   6.0                  h9df7e31_2  
  openssl                   1.0.2m               h8cfc7e7_0  
  pip                       9.0.1            py36h6c6f9ce_4  
  python                    3.6.2               hca45abc_19  
  readline                  7.0                  ha6073c6_4  
  setuptools                36.5.0           py36he42e2e1_0  
  sqlite                    3.20.1               hb898158_2  
  tk                        8.6.7                hc745277_3  
  wheel                     0.29.0           py36he7f4e38_1  
  xz                        5.2.3                h55aa19d_2  
  zlib                      1.2.11               ha838bed_2  
  </code></pre>
  
  <p>edit 2:</p>
  
  <p>Just to add some information, trying to access core OpenCV functions seems to work okay, its only functions that are part of OpenCV_Contrib that seem to be failing to install.</p>
  
  <p>Output of python -v</p>
  
  <pre><code>import _frozen_importlib # frozen
  import _imp # builtin
  import sys # builtin
  import '_warnings' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import '_thread' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import '_weakref' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import '_frozen_importlib_external' # &lt;class '_frozen_importlib.FrozenImporter'&gt;
  import '_io' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import 'marshal' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import 'posix' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import _thread # previously loaded ('_thread')
  import '_thread' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import _weakref # previously loaded ('_weakref')
  import '_weakref' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  # installing zipimport hook
  import 'zipimport' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  # installed zipimport hook
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/__pycache__/__init__.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/__init__.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/__pycache__/__init__.cpython-36.pyc'
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/codecs.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/codecs.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/codecs.cpython-36.pyc'
  import '_codecs' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import 'codecs' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb07837fd0&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/__pycache__/aliases.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/aliases.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/__pycache__/aliases.cpython-36.pyc'
  import 'encodings.aliases' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb077cf9b0&gt;
  import 'encodings' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb07837b38&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/__pycache__/utf_8.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/utf_8.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/__pycache__/utf_8.cpython-36.pyc'
  import 'encodings.utf_8' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb077dc7b8&gt;
  import '_signal' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/__pycache__/latin_1.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/latin_1.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/encodings/__pycache__/latin_1.cpython-36.pyc'
  import 'encodings.latin_1' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb077e02e8&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/io.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/io.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/io.cpython-36.pyc'
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/abc.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/abc.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/abc.cpython-36.pyc'
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/_weakrefset.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/_weakrefset.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/_weakrefset.cpython-36.pyc'
  import '_weakrefset' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb077e7240&gt;
  import 'abc' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb077e08d0&gt;
  import 'io' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb077e0518&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/site.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/site.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/site.cpython-36.pyc'
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/os.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/os.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/os.cpython-36.pyc'
  import 'errno' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/stat.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/stat.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/stat.cpython-36.pyc'
  import '_stat' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import 'stat' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0778a518&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/posixpath.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/posixpath.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/posixpath.cpython-36.pyc'
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/genericpath.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/genericpath.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/genericpath.cpython-36.pyc'
  import 'genericpath' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0778cef0&gt;
  import 'posixpath' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0778abe0&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/_collections_abc.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/_collections_abc.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/_collections_abc.cpython-36.pyc'
  import '_collections_abc' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb07796550&gt;
  import 'os' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb07779e48&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/_sitebuiltins.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/_sitebuiltins.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/_sitebuiltins.cpython-36.pyc'
  import '_sitebuiltins' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0777c278&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/sysconfig.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/sysconfig.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/sysconfig.cpython-36.pyc'
  import 'sysconfig' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0774a9b0&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/_sysconfigdata_m_linux_x86_64-linux-gnu.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/_sysconfigdata_m_linux_x86_64-linux-gnu.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/_sysconfigdata_m_linux_x86_64-linux-gnu.cpython-36.pyc'
  import '_sysconfigdata_m_linux_x86_64-linux-gnu' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0775e198&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/_bootlocale.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/_bootlocale.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/_bootlocale.cpython-36.pyc'
  import '_locale' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import '_bootlocale' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0776d198&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/types.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/types.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/types.cpython-36.pyc'
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/functools.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/functools.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/functools.cpython-36.pyc'
  import '_functools' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/collections/__pycache__/__init__.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/collections/__init__.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/collections/__pycache__/__init__.cpython-36.pyc'
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/operator.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/operator.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/operator.cpython-36.pyc'
  import '_operator' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import 'operator' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0646e048&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/keyword.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/keyword.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/keyword.cpython-36.pyc'
  import 'keyword' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0647a2b0&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/heapq.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/heapq.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/heapq.cpython-36.pyc'
  # extension module '_heapq' loaded from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/lib-dynload/_heapq.cpython-36m-x86_64-linux-gnu.so'
  # extension module '_heapq' executed from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/lib-dynload/_heapq.cpython-36m-x86_64-linux-gnu.so'
  import '_heapq' # &lt;_frozen_importlib_external.ExtensionFileLoader object at 0x7fbb0647afd0&gt;
  import 'heapq' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0647aac8&gt;
  import 'itertools' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/reprlib.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/reprlib.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/reprlib.cpython-36.pyc'
  import 'reprlib' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb06472780&gt;
  import '_collections' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  import 'collections' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0644d710&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/weakref.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/weakref.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/weakref.cpython-36.pyc'
  import 'weakref' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0644db00&gt;
  import 'functools' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb06440eb8&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/collections/__pycache__/abc.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/collections/abc.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/collections/__pycache__/abc.cpython-36.pyc'
  import 'collections.abc' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb06441b70&gt;
  import 'types' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb06440240&gt;
  import 'site' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb077eab70&gt;
  Python 3.6.2 |Anaconda, Inc.| (default, Oct  5 2017, 07:59:26) 
  [GCC 7.2.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  # extension module 'readline' loaded from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/lib-dynload/readline.cpython-36m-x86_64-linux-gnu.so'
  # extension module 'readline' executed from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/lib-dynload/readline.cpython-36m-x86_64-linux-gnu.so'
  import 'readline' # &lt;_frozen_importlib_external.ExtensionFileLoader object at 0x7fbb0643aa90&gt;
  import 'atexit' # &lt;class '_frozen_importlib.BuiltinImporter'&gt;
  # /home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/rlcompleter.cpython-36.pyc matches /home/violet/.conda/envs/visualunderstanding/lib/python3.6/rlcompleter.py
  # code object from '/home/violet/.conda/envs/visualunderstanding/lib/python3.6/__pycache__/rlcompleter.cpython-36.pyc'
  import 'rlcompleter' # &lt;_frozen_importlib_external.SourceFileLoader object at 0x7fbb0643aba8&gt;
  </code></pre>