Skip to content

Instantly share code, notes, and snippets.

@romanegloo
Created February 2, 2019 03:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romanegloo/458a4d206e2fca8105348c332257ffe7 to your computer and use it in GitHub Desktop.
Save romanegloo/458a4d206e2fca8105348c332257ffe7 to your computer and use it in GitHub Desktop.
PyLucene Installation

On Mac OS

Java

Both of Oracle Java 1.8 and Apple's Java 1.6 are required. You can download Oracle Java 1.8 from here.

For Apple's Java 1.6, download the package from here and install it.

Set JAVA_HOME to make Java1.8 as default. Add this line to .baserc or .bash_profile,

export JAVA_HOME=`/usr/libexec/java_home`

and reload the configuration

source ~/.bashrc

JCC

JCC is a C++ code generator that produces a C++ object interface wrapping a Java library. Build JCC module. JCC requires JDK and C++ compiler.

First download the source file, and build it using python setuptools.

$ cd ~/Downloads
$ svn co http://svn.apache.org/repos/asf/lucene/pylucene/trunk/jcc jcc
$ cd jcc
$ python setup.py build
$ sudo python setup.py install

ANT

ANT is a Java library and command-line tool that help building software. Download a binary or source file from here.

$ wget http://mirror.olnevhost.net/pub/apache//ant/binaries/apache-ant-1.10.5-bin.zip
$ unzip apache-ant-1.10.5-bin.zip
$ sudo mv apache-ant-1.10.5-bin.zip /usr/local/

Add the bin path to the shell environment.

export PATH="/usr/local/apache-ant-1.10.5/bin:${PATH}"

PyLucene

Download the latest PyLucene and compile it.

$ cd ~/Downloads
$ wget http://apache.claz.org/lucene/pylucene/pylucene-7.6.0-src.tar.gz
$ tar zxvf pylucene-7.6.0-src.tar.gz
$ cd pylucene-7.6.0

Change the Makefile appropriately. I modified the settings as below:

PREFIX_PYTHON=/usr/local
ANT=/usr/local/apache-ant-1.10.5/bin/ant
PYTHON=$(PREFIX_PYTHON)/bin/python3
JCC=$(PYTHON) -m jcc --shared --arch x86_64
NUM_FILES=8

Run make

$ make
... It will take a while compiling files
$ make test
$ sudo make install

Check if it runs without a problem.

$ python3 -c "import lucene; lucene.initVM()"

On Linux

JAVA

Install Oracle JAVA 1.8

First, add the PPA, and update the package index

sudo add-apt-repository ppa:webupd8team/java
sudo apt update

Install the JAVA installer script

sudo apt install oracle-java8-installer

Check if JAVA 1.8 is installed correctly

javac -version

Set the JAVA environment variables

sudo apt install oracle-java8-set-default

JCC

JCC is a C++ code generator that produces a C++ object interface wrapping a Java library. Build JCC module. JCC requires JDK and C++ compiler.

First download the source file, and build it using python setuptools.

$ cd ~/Downloads
$ svn co http://svn.apache.org/repos/asf/lucene/pylucene/trunk/jcc jcc
$ cd jcc
$ python setup.py build
$ sudo python setup.py install

ANT

ANT is a Java library and command-line tool that help building software. Download a binary or source file from here.

$ wget http://mirror.olnevhost.net/pub/apache//ant/binaries/apache-ant-1.10.5-bin.zip
$ unzip apache-ant-1.10.5-bin.zip
$ sudo mv apache-ant-1.10.5-bin.zip /usr/local/share/

Add the bin path to the shell environment.

export PATH="/usr/local/share/apache-ant-1.10.5/bin:${PATH}"

PyLucene

Download the latest PyLucene and compile it.

$ cd ~/Downloads
$ wget http://apache.claz.org/lucene/pylucene/pylucene-7.6.0-src.tar.gz
$ tar zxvf pylucene-7.6.0-src.tar.gz
$ cd pylucene-7.6.0

Change the Makefile appropriately. I modified the settings as below:

PREFIX_PYTHON=/usr/local
ANT=/usr/local/apache-ant-1.10.5/bin/ant
PYTHON=$(PREFIX_PYTHON)/bin/python3
JCC=$(PYTHON) -m jcc --arch x86_64
NUM_FILES=8

Run make

$ make
... It will take a while compiling files
$ make test
$ sudo make install

Check if it runs without a problem.

$ python3 -c "import lucene; lucene.initVM()"
@gpdfgpdf
Copy link

Hi, same struggle here. How did you fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment