[转载] Imported target “pybind11::module“ includes non-existent path + Python路径指定错误

CMakeLists.txt

cmake_minimum_required(VERSION 3.18)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(xiaoHelloWorld)

add_subdirectory(extern/pybind11)

pybind11_add_module(xiaoHelloWorld xiao.cpp)
mkdir build
cd build
cmake ..
make check -j 4

报错错误大意是 cmake 不能找到正确的Python版本.

CMake Error in CMakeLists.txt:
  Imported target "pybind11::module" includes non-existent path

    "/usr/include/python3.6m"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

给cmake参数指定一下 Python 路径就行

 -DPYTHON_EXECUTABLE=~/opt/anaconda3/bin/python 

不知道在哪的话,就:

$ which python
/usr/bin/python
$ cmake .. -DPYTHON_EXECUTABLE=/usr/bin/python

参考自:
https://bitbucket.org/mituq/muq2/issues/23/imported-target-pybind11-module-includes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值