JNI, Python ImportError

Discussion in 'Java' started by Tero Pihlajakoski, Feb 10, 2004.

  1. Hi,

    I'm embedding Python to Java through JNI, and everything works ok, except
    if I try to import stuff that's loaded from <PYTHONPATH>/lib-dynload/,
    Python will give me an ImportError, JNI code:

    : PyRun_SimpleString( "import math\n" );

    ImportError: /usr/lib/python2.3/lib-dynload/math.so: undefined
    symbol: PyExc_OverflowError

    Anyone else tried this / found the solution / having this
    problem? Could it be some security restriction of JNI? Can I alter those?
    The system is Linux using Sun's JVM 1.4.2_03 and Python 2.3.2, and can't
    use Jython due to the missing C API (wxPython etc.)...


    Thanks,
    Tero

    --
     
    Tero Pihlajakoski, Feb 10, 2004
    #1
    1. Advertising

  2. On Tue, 10 Feb 2004 16:55:31 +0000 (UTC), Tero Pihlajakoski wrote:
    > I'm embedding Python to Java through JNI, and everything works ok, except
    > if I try to import stuff that's loaded from <PYTHONPATH>/lib-dynload/,
    > Python will give me an ImportError, JNI code:
    >
    >: PyRun_SimpleString( "import math\n" );
    >
    > ImportError: /usr/lib/python2.3/lib-dynload/math.so: undefined
    > symbol: PyExc_OverflowError
    >
    > Anyone else tried this / found the solution / having this problem?
    > Could it be some security restriction of JNI? Can I alter those? The
    > system is Linux using Sun's JVM 1.4.2_03 and Python 2.3.2, and can't
    > use Jython due to the missing C API (wxPython etc.)...


    Whatever the cause it has nothing to do with JNI per se.

    Did you link with libpython.a (libpython2.3.a) or similar library? At
    any rate I believe that's where the missing symbol is defined.

    I'd suggest you ask in a python forum.

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
     
    Gordon Beaton, Feb 11, 2004
    #2
    1. Advertising

  3. Gordon Beaton <> wrote:
    > On Tue, 10 Feb 2004 16:55:31 +0000 (UTC), Tero Pihlajakoski wrote:
    >> I'm embedding Python to Java through JNI, and everything works ok, except
    >> if I try to import stuff that's loaded from <PYTHONPATH>/lib-dynload/,
    >> Python will give me an ImportError, JNI code:
    >>
    >>: PyRun_SimpleString( "import math\n" );
    >>
    >> ImportError: /usr/lib/python2.3/lib-dynload/math.so: undefined
    >> symbol: PyExc_OverflowError
    >>
    >> Anyone else tried this / found the solution / having this problem?
    >> Could it be some security restriction of JNI? Can I alter those? The
    >> system is Linux using Sun's JVM 1.4.2_03 and Python 2.3.2, and can't
    >> use Jython due to the missing C API (wxPython etc.)...


    > Whatever the cause it has nothing to do with JNI per se.


    Might be, but it's definitely Java-related since running the same code
    from a plain C source causes no error. And still, stuff like
    PyRun_SimpleString( "import sys\nprint sys.path\n" ) work ok from JNI
    (because no dynamic libraries need to be loaded as sys is a built-in /
    statically already linked).

    > Did you link with libpython.a (libpython2.3.a) or similar library? At
    > any rate I believe that's where the missing symbol is defined.


    Yes, I did. The missing symbol is defined in .../math.so, but for some
    reason Python can't get access to it when embedded through JNI (?)...

    > I'd suggest you ask in a python forum.


    > /gordon


    - Tero

    --
     
    Tero Pihlajakoski, Feb 11, 2004
    #3
    1. Advertising

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. Alex Hunsley

    IBM's JNI fails where Sun's JNI works

    Alex Hunsley, Nov 3, 2003, in forum: Java
    Replies:
    4
    Views:
    886
    Alex Hunsley
    Nov 4, 2003
  2. Pasturel Jean-Louis

    Porting JNI Windows under JNI LINUX + Wine ?

    Pasturel Jean-Louis, Feb 29, 2004, in forum: Java
    Replies:
    5
    Views:
    947
    Pasturel Jean-Louis
    Mar 3, 2004
  3. vasanth
    Replies:
    0
    Views:
    2,786
    vasanth
    Jan 25, 2005
  4. vasanth
    Replies:
    0
    Views:
    643
    vasanth
    Jan 25, 2005
  5. bgabrhelik
    Replies:
    0
    Views:
    897
    bgabrhelik
    Sep 29, 2009
Loading...

Share This Page