pylucene installation problem on Ubuntu 9.04

KK dioxide.software at gmail.com
Fri Aug 7 07:09:25 EDT 2009


I tried doing something silly.
I went to the directory "/usr/local/lib/python2.6/site-packages" and
then tried to compile/run the file called PyLucene.py the way we
compile/run python scripts, then from there i started the python
interpreter by typing python ( which is actually python2.6), then i
tried to import that module, [un]fortunately it din't give that error
message but something else, you can see below:

kk-laptop:/usr/local/lib/python2.6/site-packages$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> indexDir = '/opt/lucene/index'
>>> import PyLucene
WARNING: could not properly read security provider files:
         file:///usr/local/gcc-3.4.6/lib/security/libgcj.security
         file:///usr/local/gcc-3.4.6/lib/security/classpath.security
         Falling back to standard GNU security provider
>>>

then tried to copy and paste my sample code for indexing data to
lucene, this way:


>>> writer = IndexWriter(indexDir, StandardAnalyzer(), True)
>>> title = "this is sample page title"
>>> content = "This is sample page content for testing pylucene tool"
>>>
>>> doc = Document()
>>> doc.add(Field("title", title, Field.Store.YES, Field.Index.TOKENIZED))
>>> doc.add(Field("content", content, Field.Store.YES, Field.Index.TOKENIZED))
>>> writer.addDocument(doc)
>>> writer.optimize()
>>>

----------------------------
and surprisingly it din't give any other error. to crosscheck things i
went to the lucene index directory and fired LUKE and luckily found
that doc being indexed by lucene, even i tried searching for some
words and found they are working fine. So Pylucene seems to be working
partially, in my case. But I think python is not able to load the
PyLucene module (btw, i din't see any __init__ scripts which, i guess,
are used for bootstrapping external modules, right?). Then what is the
fix for this? do we have to add some __init__ scripts to make python
load PyLucene module when it starts? do i sound silly? What is the
best/easiest way to get this working? I've spend quite a lot of time
jsut to make PyLucene running but to no avail.
BTW, I tried to start the python interpreter from other locations and
tried imporitn this PyLucene module but got the same irritating error
message saying "module not found".
Also trying to run my sample indexer from cli using the normal way[kk-
laptop$ python indexer.py] gave the same error message.

Any help/advice is highly appreciated.
Thanks,
KK

On Aug 7, 8:22 am, KK <dioxide.softw... at gmail.com> wrote:
> On Aug 7, 12:38 am, Jon Clements <jon... at googlemail.com> wrote:
>
>
>
> > On 6 Aug, 19:49, KK <dioxide.softw... at gmail.com> wrote:
>
> > > hi all,
> > > I've trying to install pylucene on my linux box from last 2 days but
> > > not able to do so. first i tried to install it using apt-get like
> > > this,
> > > kk-laptop$ sudo apt-get install pylucene
> > > and it did install python2.5, python2.5-minimal and pylucene. I must
> > > mention one thing that I already had python2.6 on my box as the
> > > default python i.e /usr/bin/python is linked to python2.6. Anyway s,
> > > now i started the python interpreter using "python" command from cli
> > > and then to make sure pylucene has been installed i tried to import
> > > the module and to my surprise it said "module pylucene not found".
> > > I thought I should enter the python2.6 env and do the same , so i
> > > tried starting the python2.6 interpreter using "python2.6" as the
> > > command and tried importing the same module and again it failed giving
> > > the same irritating message.
> > >  As a final try i pulled the source code of pylucene and as per the
> > > comments given there in the README file, copied the mentioned files to
> > > site-packages directory of python2.6 and then tried importing the
> > > module and then got the same error message saying no module name
> > > pylucene is present. I'm sick of this error !
> > > Can someone point me what is the issue? If it is due to multiple
> > > version of python running on box, can someone tell me which one to
> > > remove or someone tell me how to get the whole thing running? I'll
> > > very much thankful to you guys.
>
> > > Thanks,
> > > KK.
>
> > If you installed using apt, have you a pylucene directory under /usr/
> > local/lib/python2.6/dist-packages/?
>
> > Also, if you run python, and import sys; print sys.path
> > whats it show?
>
> > Jon.
>
> Yes I've a dirctory called dist-packages under python2.6 but that
> doesn't contain anything on pylucene [it has lupyne, which i installed
> day before yesterday and importing lupyne doesn't give any error msg,
> but again it is dependent on pylucene]
> # for python the output is :
> ------------------------------
> kk-laptop$ python
> Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> import sys
> >>> print sys.path
>
> ['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/
> python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/
> lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/
> dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/var/
> lib/python-support/python2.6', '/usr/lib/python2.6/dist-packages/
> gtk-2.0', '/var/lib/python-support/python2.6/gtk-2.0', '/usr/local/lib/
> python2.6/dist-packages']
>
> -------------------------------
>
> for python2.5 this is the output:
> kk-laptop$ python2.5
> Python 2.5.4 (r254:67916, Apr  4 2009, 17:55:16)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> import sys
> >>> print sys.path
>
> ['', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/
> python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/
> python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/
> lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/
> gst-0.10', '/var/lib/python-support/python2.5', '/usr/lib/python2.5/
> site-packages/gtk-2.0', '/var/lib/python-support/python2.5/gtk-2.0']
>
> --------------------------------
>
> and for python2.6 the output is this:
> kk-laptop$ python2.6
> Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> import sys
> >>> print sys.path
>
> ['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/
> python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/
> lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/
> dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/var/
> lib/python-support/python2.6', '/usr/lib/python2.6/dist-packages/
> gtk-2.0', '/var/lib/python-support/python2.6/gtk-2.0', '/usr/local/lib/
> python2.6/dist-packages']
>
> From all of the above what I can see is we don't have any directory
> named dist-packages under python2.5 but we've one under 2.6, then
> where did all those pylucene files got installed to after i installed
> it using apt-get? Any ideas?
>
> Thanks
> KK




More information about the Python-list mailing list