I have added the directory containing jcc.dll, which is the jcc egg,
to PATH. It is not necessary, because the code in jcc\__init__.py
automatically adds the directory to PATH. Anyway I have added it, and
the result is the same.

I couldn't not import lucene module, so there is way to run initVM().

I can run pyLucene in Python 2.6.4, and the postgres' python is also 2.6.4

On Tue, Nov 8, 2011 at 2:57 PM, Andi Vajda <va...@apache.org> wrote:
>
> On Nov 7, 2011, at 22:28, Jiang Fung Wong <jiangfung.w...@jamiq.com> wrote:
>
>> Dear All,
>>
>> I got this error when trying to import pylucene inside Postgres PL/Python.
>>
>> ERROR:  ('Traceback (most recent call last):
>>  File "<string>", line 17, in __plpython_procedure_testing_1517611
>>  File 
>> "d:\\ve\\Lib\\site-packages\\lucene-3.4.0-py2.6-win32.egg\\lucene\\__init__.py",
>> line 5, in <module>
>>    import jcc, _lucene
>>  File 
>> "d:\\ve\\Lib\\site-packages\\jcc-2.11-py2.6-win32.egg\\jcc\\__init__.py",
>> line 34, in <module>
>>    from _jcc import initVM
>> ImportError: DLL load failed: The specified module could not be found.
>> ',)
>>
>> I have no isue importing jvm.dll using ctypes, 
>> ctypes.windll.LoadLibrary("jvm")
>> The path to jvm.dll is also listed on the PATH environment variable,
>> from the output of the statement plpy.info(os.environ['Path']) below.
>> I have no problem importing pylucene on my system's python
>> interpretor, outside Postgres.
>>
>> How to solve this?
>
> You probably need to set some PATH environment variable to contain the 
> directory that contains the _jcc.dll for the process Postgres is running in.
> A Postgres windows user mailing list may have more details for you.
> Don't forget that you also must run initVM() from the process' main thread 
> and that each thread calling into PyLucene must call attachCurrentThread() 
> too.
>
> Last but not least, is the version of Python embedded in Postgres the same as 
> the one you used to build PyLucene ?
>
> Andi..
>
>>
>> Here's my code:
>>
>> drop function testing();
>> CREATE FUNCTION testing()
>>  RETURNS text
>> AS $$
>>
>> import os
>> import ctypes
>> ctypes.windll.LoadLibrary("jvm")
>> plpy.info(os.environ['Path'])
>>
>> try:
>>    import lucene
>> except Exception, e:
>>    import traceback
>>    plpy.error(traceback.format_exc())
>> else:
>>    return ""
>>
>> $$ LANGUAGE plpythonu;
>

Reply via email to