Yuheng Zou
Yuheng Zou

Reputation: 183

Link Python3 with CMake on Mac OS X

I am using CMake. I want to link Python3 libraries to my project. I installed Python3 by homebrew, and write CMakeLists.txt like this:

find_package(PythonLibs 3.6 REQUIRED)

But then it gave me an error:

Could NOT find PythonLibs: Found unsuitable version "2.7.10", but required
is at least "3.6" (found /usr/lib/libpython2.7.dylib)

This error happens on Mac OS X. Could anybody tell me how to solve it? Thanks.

Upvotes: 5

Views: 2854

Answers (3)

SLIP
SLIP

Reputation: 11

Even easier solution - you can download "macOS 64-bit installer" from python official site and install it.

Upvotes: 1

Jon Deaton
Jon Deaton

Reputation: 4379

I had this same error on Mac OSX and installing python3 with Homebrew did not fix it. Following the advice found on this post, cleaning my build directory did fix the problem and Python3.6 was found.

Upvotes: 1

Yuheng Zou
Yuheng Zou

Reputation: 183

I have solved this problem so I am answering this question by myself.

Python installed by Homebrew cannot be found by CMake. However, you can build Python from source and make install it, then CMake can find this.

Upvotes: 0

Related Questions