【问题标题】:How to fix : pyconfig.h not found with Anaconda如何修复:在 Anaconda 中找不到 pyconfig.h
【发布时间】:2019-01-11 19:11:20
【问题描述】:

我正在为库的 python 绑定设置 boost-python。以前,boost 已安装但链接到 python2.7。在经历了一些磨难之后,之前安装的 boost 的所有内容都消失了,我正在尝试安装新的 boost。

我使用 Linux Mint 作为记录,Anaconda 使用 python 3.6.8。 它在 CLI 中正常工作:python --version 提供 3.6.8

然后我开始按照说明构建 boost :https://www.boost.org/users/history/version_1_69_0.html

我从其他线程得到的就是这样做:

sudo apt-get install python3-dev

我不确定我应该这样做,因为我有 anaconda3,但无论如何,我做到了。

./bootstrap.sh

这里创建了 project-config.jam 文件,关于 python 的行说:

using python : 3.6 : /home/myUser/anaconda3 ; 

然后我继续使用 b2 构建:

sudo ./b2 --with-python -j8 install

安装失败,上面写满了文字:

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

当我在 ~/anaconda3/include/python3.6m 中搜索时,pyconfig.h 文件按预期放在那里

我应该向 b2 或 bootstrap 提供其他信息吗?

【问题讨论】:

    标签: python c++ binding


    【解决方案1】:

    我在使用 python Anaconda 和 python 3.7.1 安装 boost 1.70 和 Anaconda3 时遇到了同样的问题。我根据这个问题找到了答案。 Ubuntu - Linking boost.python - Fatal error: pyconfig cannot be found

    首先要解决这个问题,你应该在Anaconda的安装目录中找到“pyconfig.h”文件。对我来说,它在“~/anaconda3/include/python3.7m”中。然后导出这个地址或者只是将这个地址添加到 .bashrc 文件中。

    export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:path/to/your/Anaconda3/include/python3.7m"
    

    把 Anaconda 的地址放在你的电脑里,而不是 path/to/your/Anaconda3。记住在此之后重新启动终端。然后再次在 boost 文件夹中运行“./b2”。它应该编译其余部分。

    【讨论】:

      猜你喜欢
      • 2014-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-07
      • 2020-12-15
      • 2017-03-15
      • 2020-12-04
      • 2019-08-17
      相关资源
      最近更新 更多