首页 > 解决方案 > 无法构建 boost python 库(致命错误:pyconfig.h:没有这样的文件或目录)

问题描述

我正在尝试在我的 ubuntu 上构建 boost python 库。但是,当我执行

./b2 --with-python

它总是返回与我相关的错误

./boost/python/detail/wrap_python.hpp:57:11: fatal error: pyconfig.h: No such file or directory
 # include <pyconfig.h>
           ^~~~~~~~~~~~

我尝试在网上查找,例如,https://github.com/boostorg/build/issues/289

按照他们的建议,我检查了我的“project-config.jam”,我发现

# Python configuration
import python ;
if ! [ python.configured ]
{
    using python : 3.7 : /home/lowlimb/anaconda3 :/home/lowlimb/anaconda3/include/python3.7m;
}

这是正确的,因此我真的不知道如何解决这个问题。谁能给我一些建议?

标签: pythonc++ubuntuboostboost-python

解决方案


除了按照其他答案的建议安装 python 开发库之外,您还可以直接指定 python 路径:

CPLUS_INCLUDE_PATH=/usr/include/python3.7 make

或者在你的情况下是这样的:

CPLUS_INCLUDE_PATH=/home/lowlimb/anaconda3/include/python3.7 ./b2

当我使用 Boost Python 编译项目时,这对我有用,但我遇到了同样的错误。


推荐阅读