Ubuntu - 链接boost.python - 致命错误:无法找到pyconfig [英] Ubuntu - Linking boost.python - Fatal error: pyconfig cannot be found

查看:674
本文介绍了Ubuntu - 链接boost.python - 致命错误:无法找到pyconfig的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些问题,现在我读了以下内容:

hello world python extension in c ++ using boost?



我试过在我的桌面上安装boost,并根据链接建议的帖子完成。我有以下代码:

  #include< boost / python.hpp> 
#include< Python.h>
使用命名空间boost :: python;

现在我尝试了以下链接:

  g ++ testing.cpp -I /usr/include/python2.7/pyconfig.h -L /usr/include/python2.7/Python.h 
-lpython2 .7

我也尝试了以下内容:

  g ++ testing.cpp -I / home / username / python / include / -L /usr/include/python2.7/Python.h -lpython2.7 

我一直收到以下错误:

  /usr/include/boost/python/detail/wrap_python.hpp:50:23:致命错误:pyconfig.h:没有这样的
文件或目录
#include< pyconfig.h>

我不知道我要出错的地方。我有boost.python安装,只有一个问题链接?

解决方案

我只是有同样的错误,问题是g ++找不到pyconfig.h(令人震惊,我知道)。对我来说,这个文件位于 /usr/include/python2.7/pyconfig.h ,所以附加 -I /usr/include/python2.7 / 应该修复它,或者您可以将目录添加到您的路径中:

  export CPLUS_INCLUDE_PATH = $ CPLUS_INCLUDE_PATH:/usr/include/python2.7/

您也可以将其添加到您的.bashrc,它会在你下一次启动你的shell时添加(你将不得不重新打开你的终端来实现更改)。

你可以找到你自己的python包含路径通过使用 find / usr / include -name pyconfig.h ,在我的情况下返回:

  /usr/include/python2.7/pyconfig.h 
/usr/include/i386-linux-gnu/python2.7/pyconfig.h


Having some issues, now I have read the following:

hello world python extension in c++ using boost?

I have tried installing boost onto my desktop, and, done as the posts suggested in terms of linking. I have the following code:

#include <boost/python.hpp>
#include <Python.h>
using namespace boost::python;

Now I have tried linking with the following:

g++ testing.cpp -I /usr/include/python2.7/pyconfig.h -L /usr/include/python2.7/Python.h
-lpython2.7

And I have tried the following as well:

g++ testing.cpp -I /home/username/python/include/ -L /usr/include/python2.7/Python.h -lpython2.7

I keep getting the following error:

/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such   
file or directory
# include <pyconfig.h>

I don't know where I am going wrong. I do have boost.python installed, there's just a problem linking?

解决方案

I just had the same error, the problem is g++ can't find pyconfig.h(shocking, I know). For me this file is located in /usr/include/python2.7/pyconfig.h so appending -I /usr/include/python2.7/ should fix it, alternatively you can add the directory to your path with:

export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/include/python2.7/"

You can also add this to your .bashrc and it will be added whenever you start your shell next(you will have to reopen your terminal to realize the changes).

You can find your own python include path by using find /usr/include -name pyconfig.h, in my case this returns:

/usr/include/python2.7/pyconfig.h
/usr/include/i386-linux-gnu/python2.7/pyconfig.h

这篇关于Ubuntu - 链接boost.python - 致命错误:无法找到pyconfig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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