5

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.

Yuheng Zou
  • 173
  • 1
  • 9

3 Answers3

1

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.

Jon Deaton
  • 3,943
  • 6
  • 28
  • 41
1

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

10 Rep
  • 2,217
  • 7
  • 19
  • 33
SLIP
  • 11
  • 2
0

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.

Yuheng Zou
  • 173
  • 1
  • 9