import numarray problems

Discussion in 'Python' started by youngdubliner@hotmail.com, Jun 16, 2004.

  1. Guest

    I'm having a problem ........

    I've stripped all my code to help isolate the problem.

    Its seems to be with importing numarray when python is embedded in C.

    I have a simple C program it Opens Python imports a script and
    then Closes Python

    like so .......

    int main(int argc,char *argv[])
    {

    int count = 0;
    PyObject *pmod;

    while ( count < 10)
    {

    /*
    ** Initialize Python
    */

    Py_Initialize();
    printf("\nOpen Python ---- >");

    pmod = PyImport_ImportModule("test");

    Py_DECREF(pmod);

    /*
    ** Close Python
    */

    Py_Finalize();
    printf("\n<---- Closed Python");


    /*
    ** Do this 10 times !
    */
    count++;

    }
    getchar();
    return(0);

    }

    and thats it !

    The script it calls is test.py its very simple , it imports numarray
    and then returns. like so .......

    -----------------------
    test.py
    -----------------------
    #Imports
    from numarray import *

    def test_func():
    return (99)
    -----------------------
    end of file
    -----------------------


    The first time it is called from my C code
    it all works fine ! ( but only the first time ! )

    In the second iteration above test .c crashes

    It has something to do with importing numarray.
    Beacase if you comment out the import line i.e

    -----------------------
    test.py
    -----------------------
    #Imports
    # Commented out !
    #from numarray import *

    def test_func():
    return (99)
    -----------------------
    end of file
    -----------------------

    its scrolls through the while loop and works fine.

    Its all very odd . any ideas ?


    I'm using Python 2.3.3 and Python 2.3 numarray - 0.8

    Thanks in advance
     
    , Jun 16, 2004
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Opal
    Replies:
    12
    Views:
    1,201
    Paul Opal
    Oct 11, 2004
  2. JPractitioner
    Replies:
    13
    Views:
    20,553
    Roedy Green
    Feb 24, 2006
  3. Vitali Gontsharuk
    Replies:
    2
    Views:
    741
    Vitali Gontsharuk
    Aug 25, 2005
  4. Artur M. Piwko

    import/from import question

    Artur M. Piwko, Jun 29, 2003, in forum: Python
    Replies:
    1
    Views:
    1,023
    Peter Hansen
    Jul 2, 2003
  5. Dennis
    Replies:
    2
    Views:
    659
    Dennis
    Aug 18, 2003
  6. Pierre Rouleau
    Replies:
    4
    Views:
    1,029
    Pierre Rouleau
    Mar 7, 2004
  7. Sonium

    Problems using numarray

    Sonium, Nov 3, 2004, in forum: Python
    Replies:
    2
    Views:
    311
  8. Andrew James
    Replies:
    1
    Views:
    1,147
    Diez B. Roggisch
    Dec 4, 2004
Loading...