I recently needed to install PyLucene for our developers on a server running Ubuntu 11.10 (Oneiric Ocelot). Unfortunately the version in the repos was much too old, so I had to build it from source. Below I will describe what I did, in the hopes it will help someone else.
First, we need to install Java
Download the source
http://apache.cyberuse.com//lucene/pylucene/
sudo apt-get install openjdk-6-jre openjdk-6-jdk ant
Download the source
http://apache.cyberuse.com//lucene/pylucene/
Extract source
Try to compile jcc (it will probably fail)
tar zxvf pylucene-x.x.x-x-src.tar.gz
Try to compile jcc (it will probably fail)
cd pylucene-x.x.x-x/jcc
sudo python setup.py build
It will fail and give you a command to add a patch to setuptools, like this:
sudo patch -d /usr/lib/python2.7/dist-packages -Nup0 < /home/johnw/personal/pylucene-3.4.0-1/jcc/jcc/patches/patch.43.0.6c11
After running that, try again
cd to the root of the archive
sudo python setup.py build
cd to the root of the archive
cd ..
Run these commands
Edit the Makefile to match your enviroment (i.e. I had to uncomment these lines)
pushd jcc
python setup.py build
sudo python setup.py install
popd
Edit the Makefile to match your enviroment (i.e. I had to uncomment these lines)
# 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=3
to look like this:
# 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=3
Install it
sudo make
sudo make install
Now we will run tests to make sure it installed correctly
sudo make test
If all tests complete okay, then you are all set. Enjoy!
If you feel this helped you, please leave a comment.
Thank you for sharing this useful tutorial!
ReplyDeleteThanks. Worked like a charm for me.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletethanks for these notes George! i am installing on ubuntu 12.04, tried to use the ancient v2.3.1 pylucene .deb before making from source. i posted a few updates re: ubuntu 12.04 64-bit, python 2.7, jdk 1.7 on stackexchange: http://stackoverflow.com/questions/12488975/only-parts-of-pylucene-are-available/
ReplyDeletesudo python setup.py build # I got a OSerr
ReplyDeletecd to the root of the archive
cd .. # must do like this?
Which "sudo python setup.py build" are you getting the error at, and what does the error say? The first one is supposed to error out, and it gives you the command to run to fix it.
Delete