Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JNI, Python ImportError

Reply
Thread Tools

JNI, Python ImportError

 
 
Tero Pihlajakoski
Guest
Posts: n/a
 
      02-10-2004
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

--

 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      02-11-2004
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
 
Reply With Quote
 
 
 
 
Tero Pihlajakoski
Guest
Posts: n/a
 
      02-11-2004
Gordon Beaton <(E-Mail Removed)> 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

--

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ImportError while Embedding python in C kaush Python 1 03-15-2008 09:36 AM
Re: PIL on Python 2.4 - ImportError: No module named _imagingft Fredrik Lundh Python 0 10-31-2006 03:54 PM
Re: PIL on Python 2.4 - ImportError: No module named _imagingft[Solved] Nico Grubert Python 0 10-31-2006 03:16 PM
PIL on Python 2.4 - ImportError: No module named _imagingft Nico Grubert Python 0 10-31-2006 03:12 PM
SWIG/IDLE/Python: F5 SHIP.py works but "import SHIP" gives "ImportError: dynamic module does not define init function (initSHIP)" Bill Davy Python 0 05-12-2005 08:48 AM



Advertisments