I'm developing a method in C++ that makes use of a Python function. I use Python embedding in C++ and everything works nice, except one thing.

The C++ program calls this script several times. The first run is completed, but when the script has to be imported for the second time, it crashes.

I've found out that the problem is an import in the Python script, the import of pylab library (matplotlib). Without it, it works nice.

So... why 'pylab' makes the script crash during the second run?

Thanks in advance!