BlogGalleryAbout meContact
My Resume
WebDOCPDF
RTFODTTXT
powered by emurse
Use OpenOffice.org Spread Firefox Affiliate Button Ubuntu GNU/Linux Perl Python SMC

Installing PyLucene 3.x in GNU\Linux

Lucene
=======
"Lucene is a high performance, scalable Information Retrieval (IR) library. It lets you add indexing and searching capabilities to your applications. Lucene is a
mature, free, open-source project implemented in Java; it’s a member of the popular Apache Jakarta family of projects, licensed under the liberal Apache Software License.
"

PyLucene
========
" PyLucene is a Python extension for accessing Java Lucene. Its goal is to allow you to use Lucene's text indexing and searching capabilities from Python. It is API compatible with the latest version of Java Lucene, version 2.9.0 as of October 13th, 2009."


I downloaded PyLucene 3.X version and tried to install. Initially I got some error. I was trying to follow the instructions given at http://lucene.apache.org/pylucene/documentation/install.html. There was a confusing statement to me "<edit setup.py to match your environment>" :-(. Where to match ?? I scrated my hed for 2 days. Finally I identified the place to edit. Insted of discussinf error I will try to explain how to install PyLucene in GNU\Linux.

Download PyLucene 3.0.0-1 source from http://www.apache.org/dyn/closer.cgi/lucene/pylucene/ .

Extract the source. Now you will be having 'pylucene-3.0.0-1' directory. Change to the directory. Then execute the command "pushd jcc". Now you will be in the jcc directory inside the PyLucene dir. Open the 'setup.py' file. You have to make some changes in the file to install it properly. In setup.py there will be portion like this

    """"
    JDK = {
            'darwin': '/System/Library/Frameworks/JavaVM.framework/Versions/Current',
            'ipod': '/usr/include/gcc',
            'linux2': '/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0',
            'sunos5': '/usr/jdk/instances/jdk1.6.0',
            'win32': 'o:/Java/jdk1.6.0_02',
    }
    """"
If you are using GNU\Linux you have to change the line "'linux2': '/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0'," . Here you have to specify the path to your Java installation. Here in the example '/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0' is the Java installation path in my system. If you are using M$ windows you have to edit the line "'win32': 'o:/Java/jdk1.6.0_02',".

Now it is time to build and install JCC .
Be superuser and execute the command "python setup.py install".
If everything is ok JCC will be installed.

Then execute the command 'popd'. Now you are in the PyLucene source dir again.

In this directory you gave to some editing . Open the 'Makefile'. There will be a portain like this in the file.

"""    #Linux     (Ubuntu 8.10 64-bit, Python 2.5.2, OpenJDK 1.6, setuptools 0.6c9)
    #PREFIX_PYTHON=/usr
    #ANT=ant
    #PYTHON=$(PREFIX_PYTHON)/bin/python
    #JCC=$(PYTHON) -m jcc --shared
    #NUM_FILES=2
"""

Uncomment the five lines followed by "#Linux     (Ubuntu 8.10 64-bit, Python 2.5.2, OpenJDK 1.6, setuptools 0.6c9)".
Now the portain should look like
"""
    #Linux     (Ubuntu 8.10 64-bit, Python 2.5.2, OpenJDK 1.6, setuptools 0.6c9)
    PREFIX_PYTHON=/usr
    ANT=ant
    PYTHON=$(PREFIX_PYTHON)/bin/python
    JCC=$(PYTHON) -m jcc --shared
    NUM_FILES=2

"""
If you are using Python 2.6 some more editing to be done. Change the line "JCC=$(PYTHON) -m jcc --shared" to "JCC=$(PYTHON) -m jcc.__main__ --shared".

Run make and make install command. If every setting is PyLucene will be installed in your system. To check your installation rum 'make test' command.

Now enjoy !!!

Happy Hacking!!!!!!!!!!!

Related Entries:
Again Python programming in Malayalam
New book in 'Head First' series with python
Graphical works with NLTK
NLTK and Indian Language corpus processing Part-III
NLTK and Indian Language corpus processing - Part-II
 Permalink