Install PyLucene 6,7,8 on Windows 10 64bit

update 2021.10: minor fixes. Tested OK with PyLucene 8.9

update 2019.10: add support for PyLucene 8.1.1

update 2019.03: add support for Pylucene 7.7.1+ and clarify some steps

update 2017.07: add support for Python 3



Install Python 2.7.x or Python 3.4+ or Anaconda (Python 2.7.x or Python 3.4+)

Install python packages: numpy, scipy and gensim

Install JDK 1.8 (64 bit) and set environment variables

*The latest JDK 1.8.x is recommended

*JDK 10+ may be incompatible

*Anaconda is recommended since some people seems to have difficulties with raw Python

*If you use raw Python instead of Anaconda, then you may need to add environment variables such as PYTHONHOME and PYTHONPATH to ensure that python can be called on command-line prompt. For Anaconda user, it is recommended to use Anaconda prompt.

  1. JAVA_HOME=C:\jdk1.8.0_06 (or other path)
  2. add %JAVA_HOME%\bin to PATH
  3. CLASSPATH=.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
  4. add CLASSPATH as an environment variable
  5. add %JAVA_HOME%\jre\bin\server to PATH
  6. Install one of the following libraries subject to your environment:
  • Visual C++ library for Python 2.7
    • (
  • Visual C++ 2015 Build Tools for Python
    • (
  • Visual Studio 2015+  (community version is enough. Choose c++ related tools and all versions of SDK to install in the VS installer)
    • (

Step 1. Install Apache Ant and set environment variables
1. specify ANT_HOME and add ANT_HOME as an environment variable
2. add %ANT_HOME%\bin to PATH
Step 2. Install cygwin 64 and set environment variables
0. When installing cygwin, choose “Devel” from “Default” to “Installed”
*the space of all packages under “Devel” category are quite large (30~70 GB). “Default” with some basic gcc/g++ tools, libraries and make/cmake utilities are already enough for PyLucene installation.
*choose “Debug” from “INSTALL” to “Unstall” or “Default” can save a lot of space.

1. specify CYGWIN_HOME and add CYGWIN_HOME as an environment variable
2. add %CYGWIN_HOME%\bin to PATH
restart your computer


Step 3. Download source code of PyLucene and extract, we obtain a directory named ‘PyLucene-6.5’
* For PyLucene 7 user, the latest Pylucene 7.7.1 is recommended because
the previous PyLucene 7.x may encouter errors during the installation

Step 4. Open Anaconda prompt, execute command under directory JCC
1. python build
2. python install
restart your computer
for Linux user, edit line 71 of to specify your JAVA home (For example, ‘linux’: JAVAHOME) or simply set a JCC_JDK environment variable sharing same value with JAVA_HOME.

Step 5. Edit PyLucene-6.5/Makefile

first comment the default configuration (by adding ‘#’) like the following
# Mac OS X 10.12 (64-bit Python 2.7, Java 1.8)
#JCC=$(PYTHON) -m jcc.__main__ –shared –arch x86_64

And then insert the following configuration (the following are just examples)

JCC=$(PYTHON) -m jcc

*for PyLucene 8 installation, set NUM_FILES=10. If encounter [WinError 267] when executing ‘make install’, execute ‘make clean’ and then ‘make install’ again.

*if the path contains blank space, you need to replace it by dos path like ‘C:/PROGRA~1’

*if you create a Anaconda environment, then change PREFIX_PYTHON to the root directory of this environment. (e.g Anaconda2/envs/ENVIRONMENT_NAME)


Step 6. Execute command ‘make’ under directory ‘PyLucene-6.5.0’ to build the whole project

*use command “make -j2” or “make -j4” to speed up

Step 7. Execute command ‘make install’ under directory ‘PyLucene-6.5.0’


Frequently Encountered Problems
1. Python (actually ‘setuptools’ package) cannot call Visual C++ (MSVC) to compile the project
solution: Rewrite PYTHON_PATH\Lib\distutils\distutils.cfg like the following


2. It fails when compiling JCC
solution: open and
find line ‘win32’: [“/EHsc”, “/D_CRT_SECURE_NO_WARNINGS”],
replace this line by

‘win32’: [“/EHsc”, “/D_CRT_SECURE_NO_WARNINGS”,”/bigobj”],

3. [WinError 267] the directory name is invalid

replace NUM_FILES=8 by NUM_FILES=10 in Makefile.

execute ‘make clean’, and then execute ‘make’ to compile the whole project again

4. JCC_JDK not found (may encounter on Linux)

set “JCC_JDK” as environment variable. The value is  same as JAVA_HOME

5. encounter “dynamic mode does not define module export function” when “import lucene” in Python prompt (may encounter on linux)

remove lucene and jcc packages by execute “pip uninstall lucene” and “pip uninstall jcc”

edit pylucene-6.5/jcc/ replace the line 71 by ‘linux’:JAVAHOME,

remove jcc/build folder and execute “make clean” under pylucene-6.5 directory.

install jcc and pylucene again