OS X cmake找不到PythonLibs 3.4 [英] OS X cmake can't find PythonLibs 3.4

查看:188
本文介绍了OS X cmake找不到PythonLibs 3.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

python和python3通过Homebrew安装在OS X Yosemite中,但是cmake无法找到PythonLibs 3,只有2:

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

CMakeLists.txt:

CMakeLists.txt:

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

获取:

-- 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:


CMakeLists.txt:

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

获取:

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



然后我将其添加到cmake列表中:



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)

,甚至将该目录复制到/usr/lib,然后得到:

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)

看起来很奇怪.

推荐答案

您需要将路径添加到环境变量"LD_LIBRARY_PATH"中的库.这样,CMake将知道在哪里寻找它们.在多个python安装中或将其安装在非标准位置时,可能会发生这种情况.这应该可以解决:

You need to add the path to the libraries in your "LD_LIBRARY_PATH" environment variable. In this way, CMake will know where to look for them. This may happen with multiple python installations or when it is installed in a non standard location. This should solve it:

export LD_LIBRARY_PATH=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib:$LD_LIBRARY_PATH

CMake命令"INCLUDE_DIRECTORIES"仅用于标头(又名/usr/include).

The CMake command "INCLUDE_DIRECTORIES" is only for headers (aka. /usr/include).

->如果我的解决方案不起作用,请确保已安装python-devel:

-> If my solution doesn't work, make sure you have python-devel installed: how to install python-devel in Mac OS?

这篇关于OS X cmake找不到PythonLibs 3.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆