cmake finds wrong python libs cmake finds wrong python libs python python

cmake finds wrong python libs


You can tell cmake where to find this PythonLibs by specifying the path to your python libraries like this:

cmake -DPYTHON_LIBRARIES=/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib .

This will then set the ${PYTHON_LIBRARIES} inside cmake to the right path.

To find out which other possible options (besides PYTHON_LIBRARIES) you can give to cmake (with the -DARG option) try running

ccmake .

Then press c to configure, and t for advanced options.

For example, you might also want to set

-DPYTHON_LIBRARY='/softwarepath/Python/Python2.7/lib/libpython2.7.so'-DPYTHON_INCLUDE='/softwarepath/Python/Python2.7/include'


The best way to solve the problem that the wrong version is found (for instance 3.0 instead of 2.7) is to specify the minimum version to find_package (this will choose any version >= 2.7):

FIND_PACKAGE(PythonLibs 2.7 REQUIRED)

or to get the exact version:

FIND_PACKAGE(PythonLibs 2.7.5 EXACT REQUIRED)


You can setup manually on cmake libs \usr\share\cmake-3.2.3\Modules\FindPythonLibs.cmake:

set(PYTHON_LIBRARY "\\usr\\lib\\python2.7")set(PYTHON_INCLUDE_DIR "\\usr\\include\\python2.7")