【问题标题】:Cannot build boost python library (fatal error: pyconfig.h: No such file or directory)无法构建boost python库(致命错误:pyconfig.h:没有这样的文件或目录)
【发布时间】:2019-12-06 06:02:28
【问题描述】:

我正在尝试在我的 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;
}

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

【问题讨论】:

    标签: python c++ ubuntu boost boost-python


    【解决方案1】:

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

    CPLUS_INCLUDE_PATH=/usr/include/python3.7 make
    

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

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

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

    【讨论】:

      【解决方案2】:

      pyconfig.hsudo apt install python-dev 一起安装

      要使用特定的 python 版本构建,您可以这样做

      ./bootstrap.sh --with-python=<path to python>
      

      例如

      ./bootstrap.sh --with-python=python3
      

      使用系统的 python3 或

      ./bootstrap.sh --with-python=$VIRTUAL_ENV/bin/python
      

      从您的虚拟环境中使用 python。

      【讨论】:

        【解决方案3】:

        为了构建 Boost-Python 或更通用,从 C/C++ 使用 Python,您需要 Python development files

        $ sudo apt install python3.7-dev
        

        【讨论】:

        • 我需要对 project-config.jam 做些什么吗?它仍在使用anaconda的python。
        猜你喜欢
        • 2023-03-29
        • 1970-01-01
        • 2018-11-03
        • 1970-01-01
        • 2014-04-28
        • 2018-02-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多