java - Load Python module to Jython from a dynamic library (.so) source -


i'm trying embbed python code inside java code. that, i'm using org.python.util.pythoninterpreter class (jython).

i noticed when import modules have add path of modules (nltk, pywsd , others).

to discover path necessary modules opened python console (2.7.12 , got file property module , added through sys.path.append method on jython (2.7.0). solution worked, when import _sqlite3 (implicit inside sqlite3 import), had trouble: no module named "_sqlite3" exists.

the directory structure that:

path add nltk module: /usr/local/lib/python2.7/dist-packages/

path add sqlite3 module: /usr/lib/python2.7/

path .so file (_sqlite3.file): /usr/lib/python2.7/lib-dynload/_sqlite3.x86_64-linux-gnu.so

some observations:

  1. _sqlite3 .__ file__ pointed dynamic library (.so) on linux;
  2. the statement import _sqlite3 works correctly on python console, not work on jython code.

anybody knows how load module in different way .so file?

my import stack displayed below.

thank's.

>>> import pywsd traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "/usr/local/lib/python2.7/dist-packages/pywsd/__init__.py", line 11, in <module>     import pywsd.lesk   file "/usr/local/lib/python2.7/dist-packages/pywsd/lesk.py", line 12, in <module>     nltk.corpus import wordnet wn   file "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 137, in <module>     nltk.stem import *   file "/usr/local/lib/python2.7/dist-packages/nltk/stem/__init__.py", line 29, in <module>     nltk.stem.snowball import snowballstemmer   file "/usr/local/lib/python2.7/dist-packages/nltk/stem/snowball.py", line 26, in <module>     nltk.corpus import stopwords   file "/usr/local/lib/python2.7/dist-packages/nltk/corpus/__init__.py", line 66, in <module>     nltk.corpus.reader import *   file "/usr/local/lib/python2.7/dist-packages/nltk/corpus/reader/__init__.py", line 105, in <module>     nltk.corpus.reader.panlex_lite import *   file "/usr/local/lib/python2.7/dist-packages/nltk/corpus/reader/panlex_lite.py", line 15, in <module>     import sqlite3   file "/usr/lib/python2.7/sqlite3/__init__.py", line 24, in <module>     dbapi2 import *   file "/usr/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>     _sqlite3 import * importerror: no module named _sqlite3 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -