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 usersImportant: 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.gzfile extracts to the directoryjdk-21.0.7+6, you may rename it totemurin-jdk-21.0.7+6or anything else that contains the wordtemurin. -
Configure
JAVA_HOMEandPATHenvironment variables.export JAVA_HOME=/usr/lib/jvm/java-21-temurin # adjust appropriately export PATH=$JAVA_HOME/bin:$PATHor in NuShell,
$env.JAVA_HOME = '/usr/lib/jvm/java-21-temurin' # adjust appropriately $env.PATH = [($env.JAVA_HOME | path join "bin")] ++ $env.PATHAdjust
JAVA_HOMEenvironment variable appropriately to point to the Temurin JDK directory.
Note thatJAVA_HOME/binshould be added to the beginning of thePATHenvironment variable.
1.2 Create environment and activate it
-
micromamba create -n ir python=3.11 micromamba activate irJCC installation requires
distutilswhich 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
buildusing pip.pip install build
2 Install PyLucene
2.1 Download and extract PyLucene
tar -xvzf pylucene-10.0.0-src.tar.gzcd pylucene-10.0.0-src
From this point onwards make sure:
- You are inside the
irenvironment (which has Python=3.11 andbuildinstalled).JAVA_HOMEis set properly to point to correct Temurin JDK 21 path.PATHcontainsJAVA_HOME/binat its beginning.
2.2 Install JCC in the ir environment
cd jcc-
Modify
setup.pyso that theJDKdictionary with key aslinuxhas same value asJAVA_HOMEi.e. the path to Temurin 21 JDK directory.For example, in my case, it would be,
JDK = { ... 'linux': '/usr/lib/jvm/java-21-temurin', ... } python setup.py buildpython setup.py install
2.3 Install PyLucene in the ir environment
-
cd ..→ Go back into the PyLucene root directory. - Edit the
MakeFileto uncomment the block mentioning Linux and Python3. -
In the uncommented block, modify the
PREFIX_PYTHONandPYTHONvariables to point to the Python location inirenvironment.For example, in my case, it would be,
PREFIX_PYTHON=/home/adi/micromamba/envs/ir PYTHON=$(PREFIX_PYTHON)/bin/pythonYou can get this location via the command
which pythonwhen theirenvironment is activated. make-
make testto 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 🥳.