Questions tagged [boost-python]

Library for intuitive and tight integration between C++ and Python.

Boost::python is a C++ library offering seamless integration of C++ and Python with reference handling, built-in and user-defined two-way type conversions, Python/C++ exception translation, function overloading, exposing class hierarchies, docstring support and more.

1337 questions
57
votes
7 answers

Ubuntu - Linking boost.python - Fatal error: pyconfig cannot be found

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…
Phorce
  • 4,424
  • 13
  • 57
  • 107
53
votes
5 answers

How to get Python exception text

I want to embed python in my C++ application. I'm using Boost library - great tool. But i have one problem. If python function throws an exception, i want to catch it and print error in my application or get some detailed information like line…
Anton Kiselev
  • 1,307
  • 1
  • 10
  • 12
48
votes
2 answers

How to import python module from .so file?

[me@hostname python]$ cat hello_world.cc #include #include #include namespace { std::string greet() { return "Helloworld"; } } using namespace boost::python; BOOST_PYTHON_MODULE(hello_world) { …
balki
  • 26,394
  • 30
  • 105
  • 151
46
votes
6 answers

std::vector to boost::python::list

I have a method in c++ that gets called from python and needs to return a python list object. I have already created the method, and its attached to an exposed class and callable from python right now... (it returns void). So the question is, how do…
mcot
  • 1,309
  • 3
  • 16
  • 19
43
votes
13 answers

Runtime error R6034 in embedded Python application

I am working on an application which uses Boost.Python to embed the Python interpreter. This is used to run user-generated "scripts" which interact with the main program. Unfortunately, one user is reporting runtime error R6034 when he tries to run…
38
votes
6 answers

How can I implement a C++ class in Python, to be called by C++?

I have a class interface written in C++. I have a few classes that implement this interface also written in C++. These are called in the context of a larger C++ program, which essentially implements "main". I want to be able to write…
hal3
  • 391
  • 1
  • 4
  • 4
36
votes
2 answers

CMake output name for dynamic-loaded library?

I'm trying to write cmake rules to build dynamic-loaded library for python using boost.python on linux. I'd like to use 'foo' for python module name. So, the library must be called foo.so. But by default, cmake uses standard rules for library…
Anton Kazennikov
  • 3,574
  • 5
  • 30
  • 38
33
votes
4 answers

boost::python: Python list to std::vector

Finally I'm able to use std::vector in python using the [] operator. The trick is to simple provide a container in the boost C++ wrapper which handles the internal vector stuff: #include #include class world { …
dmorlock
  • 1,993
  • 4
  • 18
  • 22
31
votes
2 answers

pass callback from python to c++ using boost::python

I want to pass callback from my python code to c++ I want my code look something like this: In C++ : typedef void (*MyCallback_t) (CallbackInfo); class MyClass {... void setcallback(MyCallback_t cb); ... } And to use it in python : import…
Igor Pavlov
  • 325
  • 3
  • 8
30
votes
8 answers

Boost and Python 3.x

How does boost.python deal with Python 3? Is it Python 2 only?
BenjaminB
  • 1,809
  • 3
  • 18
  • 32
29
votes
3 answers

Writing Python bindings for C++ code that use OpenCV

I'm trying to write a python wrapper for some C++ code that make use of OpenCV but I'm having difficulties returning the result, which is a OpenCV C++ Mat object, to the python interpreter. I've looked at OpenCV's source and found the file cv2.cpp…
lightalchemist
  • 10,031
  • 4
  • 47
  • 55
29
votes
5 answers

how to return numpy.array from boost::python?

I would like to return some data from c++ code as a numpy.array object. I had a look at boost::python::numeric, but its documentation is very terse. Can I get an example of e.g. returning a (not very large) vector to python? I don't mind…
eudoxos
  • 18,545
  • 10
  • 61
  • 110
27
votes
1 answer

Boost::Python, converting tuple to Python works, vector does not

I've been using Boost::Python for a while, and everything always turned out ok. However yesterday I was trying to find out why a particular type I thought I had registered (a tuple) was giving me errors when I was trying to access it from…
Svalorzen
  • 5,353
  • 3
  • 30
  • 54
25
votes
2 answers

Build Boost with multiple Python versions

I use several versions of Python on my computer : 2.6.6, 2.7.6 and 2.7.9. When I compile Boost with boost-python, I have to give the Python to use in argument. If I want compatibility, have I to compile Boost for each Python version ? (it's quite…
Caduchon
  • 4,574
  • 4
  • 26
  • 67
25
votes
6 answers

boost::python Export Custom Exception

I am currently writing a C++ extension for Python using Boost.Python. A function in this extension may generate an exception containing information about the error (beyond just a human-readable string describing what happened). I was hoping I…
Jack Edmonds
  • 31,931
  • 18
  • 65
  • 77
1
2 3
88 89