Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OS X cmake can't find PythonLibs 3.4

python and python3 are installed in OS X Yosemite via Homebrew, but cmake fails to find PythonLibs 3, only 2:


CMakeLists.txt:

set(Python_ADDITIONAL_VERSIONS 3.4)
FIND_PACKAGE(PythonInterp REQUIRED)
FIND_PACKAGE(PythonLibs 3.4 REQUIRED)

get:

-- Found PythonInterp: /usr/local/bin/python3.4 (found suitable version "3.4.3", minimum required is "3.4")
-- Found PythonLibs: /usr/lib/libpython3.4.dylib (found version "2.7.6"

CMakeLists.txt:

set(Python_ADDITIONAL_VERSIONS 3.4)
FIND_PACKAGE(PythonInterp 3.4 REQUIRED)
FIND_PACKAGE(PythonLibs 3.4 REQUIRED)

get:

Could NOT find PythonLibs: Found unsuitable version "2.7.6", but required
is at least "3.4" (found PYTHON_LIBRARY-NOTFOUND)


Then I added this to cmake lists:

INCLUDE_DIRECTORIES(/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib)
INCLUDE_DIRECTORIES(/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/include/python3.4m)

and even copied that directories to /usr/lib, and then got:

Could NOT find PythonLibs: Found unsuitable version "2.7.6", but required
is at least "3.4" (found /usr/lib/libpython3.4.dylib)

that looks weird.

like image 687
iskhakovt Avatar asked Nov 23 '25 16:11

iskhakovt


1 Answers

It appears the correct version of Python is found in your CMake configuration, but locations of the libraries also needs to be set. Depending on your installation/configuration the location of the libraries might vary, although in the configuration you'll want something similar:

PYTHON_LIBRARIES=/Library/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4m.dylib
PYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m

http://www.cmake.org/cmake/help/v3.0/module/FindPythonLibs.html

like image 52
l'L'l Avatar answered Nov 26 '25 05:11

l'L'l



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!