Embedding numpy works once, but not twice??

David Cournapeau cournape at gmail.com
Sun Feb 1 01:27:18 EST 2009


On Sun, Feb 1, 2009 at 2:47 PM, Deepak Chandran
<dchandran1 at tinkercell.com> wrote:
> I have a program in which I have successfully embedded Python. Now, I want
> to include NumPy as well (and other modules). I am able to import numpy
> once. Then I close the python console in my program and then re-open it.
> When I try to import numpy for a second time, the program crashes. Below is
> a simple version of the problem.
> The main() import numpy twice. The first import works fine -- prints "no
> errors.". But the second load crashes the program. What is going on here?
>
> By the way, this is all in Windows (XP and Vista have same problem) using
> python25.dll (since numpy does not work for python26.dll). I am using MinGW
> compiler.

FYI, numpy can work with python 2.6 if you build from recent svn.
numpy 1.3.0 will have 2.6 binaries

I can't really help you for your problem, I am not familiar with
python embedding. But inside python, when doing a double import,
doesn't python check against double import (e.g. the second time, it
does almost nothing) ? Is this specific to numpy, or other python
modules do that as well ?

cheers,

David



More information about the Python-list mailing list