机器环境:Ubuntu 16.04,Java 1.8
- 安装ANT:
|
|
下载pylucene-4.10.1-1或者pylucene-6.5.0包,并解压。
注意,不要去pylucene的github仓库https://github.com/svn2github/pylucene下载,其中缺少部分文件。
当执行make命令时会报错:
12345678910> make> mkdir -p lucene-java-7.4.0> tar -C ~/apache/lucene.git -cf - lucene | tar -C lucene-java-7.4.0 -xvf -> tar: ~/apache/lucene.git: Cannot open: No such file or directory> tar: Error is not recoverable: exiting now> tar: This does not look like a tar archive> tar: Exiting with failure status due to previous errors> Makefile:191: recipe for target 'lucene-java-7.4.0' failed> make: *** [lucene-java-7.4.0] Error 2>-
pylucene-4.10.1-1
进入jcc,修改setup.py:
12345678910JDK = {'darwin': JAVAHOME or JAVAFRAMEWORKS,'ipod': '/usr/include/gcc','linux2': '/usr/lib/jvm/java-8-oracle',# 'linux2': '/usr/lib/jvm/java-7-openjdk-amd64','sunos5': '/usr/jdk/instances/jdk1.6.0','win32': JAVAHOME,'mingw32': JAVAHOME,'freebsd7': '/usr/local/diablo-jdk1.6.0'}执行下面的命令:
12sudo python setup.py buildsudo python setup.py install验证JCC安装成功:
1python -m jccpylucene-6.5.0
进入jcc文件夹,
执行下面的命令:
12sudo python setup.py buildsudo python setup.py install验证JCC安装成功:
1python -m jcc
-
根据系统环境修改Makefile文件:
123456PREFIX_PYTHON=/usr#ANT=JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 /usr/bin/antANT=JAVA_HOME=/usr/lib/jvm/java-8-oracle /usr/bin/antPYTHON=$(PREFIX_PYTHON)/bin/pythonJCC=$(PYTHON) -m jcc --sharedNUM_FILES=812345PREFIX_PYTHON=/usrANT=JAVA_HOME=/usr/lib/jvm/java-8-oracle /usr/bin/antPYTHON=$(PREFIX_PYTHON)/bin/pythonJCC=$(PYTHON) -m jcc --sharedNUM_FILES=8执行下面的命令:
12makesudo make install验证lucene安装成功:
1python -c "import lucene" 遇到的问题
执行make命令时报错:
12345678...BUILD SUCCESSFULTotal time: 12 secondsICU not installed/opt/apache/pylucene/_install/bin/python -m jcc --shared --jar lucene-java-6.5.0/lucene/build/core/lucene-core-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/analysis/common/lucene-analyzers-common-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/memory/lucene-memory-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/highlighter/lucene-highlighter-6.5.0.jar --jar build/jar/extensions.jar --jar lucene-java-6.5.0/lucene/build/queries/lucene-queries-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/queryparser/lucene-queryparser-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/sandbox/lucene-sandbox-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/analysis/stempel/lucene-analyzers-stempel-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/grouping/lucene-grouping-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/join/lucene-join-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/facet/lucene-facet-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/suggest/lucene-suggest-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/expressions/lucene-expressions-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/analysis/kuromoji/lucene-analyzers-kuromoji-6.5.0.jar --jar lucene-java-6.5.0/lucene/build/misc/lucene-misc-6.5.0.jar --use_full_names --include lucene-java-6.5.0/lucene/expressions/lib/antlr4-runtime-4.5.1-1.jar --include lucene-java-6.5.0/lucene/expressions/lib/asm-5.1.jar --include lucene-java-6.5.0/lucene/expressions/lib/asm-commons-5.1.jar --package java.lang java.lang.System java.lang.Runtime --package java.util java.util.Arrays java.util.Collections java.util.HashMap java.util.HashSet java.util.TreeSet java.lang.IllegalStateException java.lang.IndexOutOfBoundsException java.util.NoSuchElementException java.text.SimpleDateFormat java.text.DecimalFormat java.text.Collator --package java.util.concurrent java.util.concurrent.Executors --package java.util.regex --package java.io java.io.StringReader --package java.nio.file java.nio.file.Path java.nio.file.Files java.nio.file.Paths --exclude org.apache.lucene.sandbox.queries.regex.JakartaRegexpCapabilities --exclude org.apache.regexp.RegexpTunnel --exclude org.apache.lucene.store.WindowsDirectory --exclude org.apache.lucene.store.NativePosixUtil --python lucene --mapping org.apache.lucene.document.Document 'get:(Ljava/lang/String;)Ljava/lang/String;' --mapping java.util.Properties 'getProperty:(Ljava/lang/String;)Ljava/lang/String;' --sequence java.util.AbstractList 'size:()I' 'get:(I)Ljava/lang/Object;' org.apache.lucene.index.IndexWriter:getReader org.apache.lucene.analysis.Tokenizer:input --version 6.5.0 --module python/collections.py --module python/ICUNormalizer2Filter.py --module python/ICUFoldingFilter.py --module python/ICUTransformFilter.py --files 8 --buildmake: /opt/apache/pylucene/_install/bin/python: Command not foundMakefile:340: recipe for target 'compile' failedmake: *** [compile] Error 127原因是:Makefile文件中的“PREFIX_PYTHON”配置错误,
1PREFIX_PYTHON=/opt/apache/pylucene/_install解决办法:按上面的Makefile修改即可。
Enjoy!
侠天,专注于大数据、机器学习和数学相关的内容,并有个人公众号:bigdata_ny分享相关技术文章。
若发现以上文章有任何不妥,请联系我。