Installing PyLucene 10.0.0 in a conda environment (on Linux)
I use
micromamba
. It is awesome for environment management. But all the commands here can be replaced with conda/mamba too.
1 Environment Setup
1.1 Setting up Java
-
Install Temurin JDK 21 (See Installation) or direct download the JDK. It is also available on the AUR for Arch Linux users.
yay -S jdk21-temurin # for arch users
Important: If you are direct downloading the JDK from the website, make sure that the extracted directory of the JDK contains the substring
temurin
. If the downloadedtar.gz
file extracts to the directoryjdk-21.0.7+6
, you may rename it totemurin-jdk-21.0.7+6
or anything else that contains the wordtemurin
. -
Configure
JAVA_HOME
andPATH
environment variables.export JAVA_HOME=/usr/lib/jvm/java-21-temurin # adjust appropriately export PATH=$JAVA_HOME/bin:$PATH
or in NuShell,
$env.JAVA_HOME = '/usr/lib/jvm/java-21-temurin' # adjust appropriately $env.PATH = [($env.JAVA_HOME | path join "bin")] ++ $env.PATH
Adjust
JAVA_HOME
environment variable appropriately to point to the Temurin JDK directory.
Note thatJAVA_HOME/bin
should be added to the beginning of thePATH
environment variable.
1.2 Create environment and activate it
-
micromamba create -n ir python=3.11 micromamba activate ir
JCC installation requires
distutils
which was a part of standard library in Python, but has been deprecated since 3.10 and is removed in 3.12.
I installed Python=3.11. -
Install
build
using pip.pip install build
2 Install PyLucene
2.1 Download and extract PyLucene
tar -xvzf pylucene-10.0.0-src.tar.gz
cd pylucene-10.0.0-src
From this point onwards make sure:
- You are inside the
ir
environment (which has Python=3.11 andbuild
installed).JAVA_HOME
is set properly to point to correct Temurin JDK 21 path.PATH
containsJAVA_HOME/bin
at its beginning.
2.2 Install JCC in the ir
environment
cd jcc
-
Modify
setup.py
so that theJDK
dictionary with key aslinux
has same value asJAVA_HOME
i.e. the path to Temurin 21 JDK directory.JDK = { ... 'linux': '/usr/lib/jvm/java-24-temurin', ... }
python setup.py build
python setup.py install
2.3 Install PyLucene in the ir
environment
-
cd ..
→ Go back into the PyLucene root directory. - Edit the
MakeFile
to uncomment the block mentioning Linux and Python3. -
In the uncommented block, modify the
PREFIX_PYTHON
andPYTHON
variables to point to the Python location inir
environment.
For example,PREFIX_PYTHON=/home/adi/.local/share/mamba/envs/ir PYTHON=$(PREFIX_PYTHON)/bin/python
You can get this location via the command
which python
when their
environment is activated. make
-
make test
to see if there were any failures. make install
2.4 Verify installation
Run the following in the Python CLI to verify the installation:
import lucene
lucene.initVM()
Congratulations! You have successfully installed PyLucene 10.0.0 🥳.