JNI, Python ImportError

T

Tero Pihlajakoski

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

--
 
G

Gordon Beaton

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
 
T

Tero Pihlajakoski

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.

- Tero

--
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top