Installing PyLucene 3.x in GNU\Linux
Written by Jaganadh GopinadhanLucene
“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 “
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
```bash
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!!!!!!!!!!!
Migrated from my old blog jaganadhg.freeflux.net
Python
PyLucene
]