[ACCEPTED]-No such file or directory" error with Boost Python-boost

Accepted answer
Score: 31

add #include <Python.h> and compile with -I/usr/include/python2.6 or whatever your 2 Python version is.

Do not forget to link 1 it with -lpython2.6 -lboost_python

Score: 16

Although it's quite late, but still, here's 3 my answer:

Make sure you have the libboost-python-dev 2 libraries installed:

sudo apt-get install libboost-python-dev

This did the trick for 1 me.

Score: 9

It looks like you are missing the Python 6 headers (Python.h etc.). Make sure you insteall 5 the -devel or -dev package for your version 4 of Python through the operating system package 3 manager. This should provide the header 2 files...

[Edit: noticed you are on ubuntu 1 so try sudo aptitude install python-dev ]

Score: 3

Building a big program by executing individual 6 commands like that can quickly get very 5 complicated. You can use a build system 4 like CMake to find the dependencies and sort 3 out the compiler commands for you.

The minimal 2 CMakeLists.txt to use CMake with a boost python project 1 is this:

project (MyProject)
cmake_minimum_required(VERSION 2.8)

include_directories (${PYTHON_INCLUDE_DIRS})

find_package(Boost 1.45.0 COMPONENTS python)
include_directories (${Boost_INCLUDE_DIRS})

add_library (
    mylibinterface SHARED  

target_link_libraries (mylibinterface

More Related questions