[C++-sig] Trouble converting data from numpy.array to c++

QUILLET Jean-Charles jean-charles.quillet at alyotech.fr
Tue May 11 14:32:34 CEST 2010

Thanks Ger,

I'll check out this, it seems very interesting.

But I'm confused because what I'm describing is working without any problem on windows using Visual Studio 2005 python 2.5 and boost 1.34 But for some reason I cant use these versions on Linux because of an incompatibility between Qt and Python 25


This is library hell ! Despite this, I'll check out the converters, but it seems a bit overkill for me. Whould you know an easy way to retrieve my values from the array ?
Thanks in advance,


De : Ger van Diepen [mailto:diepen at astron.nl]
Envoyé : mardi 11 mai 2010 12:25
À : QUILLET Jean-Charles; cplusplus-sig at python.org
Objet : [Spam Probable] Re: [C++-sig] Trouble converting data from numpy.array to c++

Hi Jean-Charles,

AFAIK there are no standard converters for the numpy scalar types to C++ types.
In pyrap it is solved by having explicit converters for numpy scalar types to C++ types (see pyrap.googlecode.com).


>>> QUILLET Jean-Charles 05/11/10 11:38 AM >>>


I've got this problem I cannot solve. I've a c++ application from which I create an array sending to python this string:

anArray = numpy.array((1, 2, 3))

After extracting the symbol "anArray" from the directory in a boost::python::object, I'm trying to extract the values in C++:

int val = bp::extract<int>(anArray[0]);

It doesn't work and raise the error:

"TypeError: No registered converter was able to produce a C++ rvalue of type int from this Python object of type numpy.int32"

What is going on ? I'm using python 2.6, last version of Numpy 1.4.1 with boost 1.38 on Linux. Looking on the list, it seems that someone had this very problem but he didn't get any answer.


Hopefully I'll have more chance !

Any idea greatly appreciated,


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100511/a991e277/attachment.html>

More information about the Cplusplus-sig mailing list