在 ubuntu 14.04(trusty tahr) 上构建 Pylucene

Building Pylucene on ubuntu 14.04(trusty tahr)(在 ubuntu 14.04(trusty tahr) 上构建 Pylucene)

本文介绍了在 ubuntu 14.04(trusty tahr) 上构建 Pylucene的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照安装说明,JCC搭建成功.

As per the installation instructions, JCC is successfully built.

安装的依赖项是:蚂蚁,openjdk-7-jdk,python-setuptools,python-dev.

Dependencies Installed were: ant, openjdk-7-jdk, python-setuptools, python-dev.

然后开始制作pylucene,在Makefile"中选择与Ubuntu 11相对应的规格.

Then procedding to make pylucene, in "Makefile" i choose specs corresponding to Ubuntu 11.

# Linux     (Ubuntu 11.10 64-bit, Python 2.7.2, OpenJDK 1.7, setuptools 0.6.16)
# Be sure to also set JDK['linux2'] in jcc's setup.py to the JAVA_HOME value
# used below for ANT (and rebuild jcc after changing it).
PREFIX_PYTHON=/usr
ANT=JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 /usr/bin/ant
PYTHON=$(PREFIX_PYTHON)/bin/python
JCC=$(PYTHON) -m jcc --shared
NUM_FILES=8

在执行sudo make"命令时遇到以下错误:

On executing "sudo make" command following error was encountered:

/usr/bin/python -m jcc --shared --jar lucene-java-4.6.1/lucene/build/core/lucene-core-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/analysis/common/lucene-analyzers-common-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/memory/lucene-memory-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/highlighter/lucene-highlighter-4.6.1.jar --jar build/jar/extensions.jar --jar lucene-java-4.6.1/lucene/build/queries/lucene-queries-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/queryparser/lucene-queryparser-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/sandbox/lucene-sandbox-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/analysis/stempel/lucene-analyzers-stempel-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/grouping/lucene-grouping-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/join/lucene-join-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/facet/lucene-facet-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/suggest/lucene-suggest-4.6.1.jar --jar lucene-java-4.6.1/lucene/build/expressions/lucene-expressions-4.6.1.jar  --use_full_names --include lucene-java-4.6.1/lucene/build/misc/lucene-misc-4.6.1.jar --include lucene-java-4.6.1/lucene/expressions/lib/antlr-runtime-3.5.jar --include lucene-java-4.6.1/lucene/expressions/lib/asm-4.1.jar --include lucene-java-4.6.1/lucene/expressions/lib/asm-commons-4.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 java.io.InputStreamReader java.io.FileInputStream java.io.DataInputStream --exclude org.apache.lucene.sandbox.queries.regex.JakartaRegexpCapabilities --exclude org.apache.regexp.RegexpTunnel --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 --version 4.6.1 --module python/collections.py --module python/ICUNormalizer2Filter.py --module python/ICUFoldingFilter.py --module python/ICUTransformFilter.py --resources lucene-java-4.6.1/lucene/analysis/icu/src/resources --files 8 --build 
  Warning: renaming static method 'toString' on class java.lang.Boolean to 'toString_' since it is shadowed by non-static method of same name.
  Warning: renaming static method 'toString' on class java.lang.Character to 'toString_' since it is shadowed by non-static method of same name.
Exception in thread "main" java.lang.NoSuchMethodException: org.apache.lucene.analysis.Tokenizer.pythonDecRef()
    at java.lang.Class.getMethod(Class.java:1665)
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/JCC-2.19-py2.7-linux-x86_64.egg/jcc/__main__.py", line 107, in <module>
    cpp.jcc(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/JCC-2.19-py2.7-linux-x86_64.egg/jcc/cpp.py", line 687, in jcc
    declares, typeset)
  File "/usr/local/lib/python2.7/dist-packages/JCC-2.19-py2.7-linux-x86_64.egg/jcc/cpp.py", line 1174, in code
    superMethod = find_method(superCls, methodName, params)
  File "/usr/local/lib/python2.7/dist-packages/JCC-2.19-py2.7-linux-x86_64.egg/jcc/cpp.py", line 310, in find_method
    if (e.getJavaException().getClass().getName() == 'java.lang.NoSuchMethodException'):
  File "/usr/local/lib/python2.7/dist-packages/JCC-2.19-py2.7-linux-x86_64.egg/jcc/cpp.py", line 51, in getJavaException
    return self.args[0]
IndexError: tuple index out of range
make: *** [compile] Error 1

关于搜索错误几老的邮件列表 被发现有类似的错误,但我无法得到任何提示.

On searching for the error few old mailing list were found which had similar errors but i was not able to get any hint out.

您能告诉我出了什么问题以及如何解决吗?

Can you please let me know what went wrong and how to fix it?

安装pyLucene之前需要先安装java Lucene吗?

Do I need to install the java Lucene before installing pyLucene?

推荐答案

按照这些说明(http://bendemott.blogspot.de/2013/11/installing-pylucene-4-451.html) 用 pylucene 安装了我的系统.在它工作之前,它很疯狂,我遇到了这个问题(在 ubuntu 上构建 Pylucene14.04(trusty tahr)) 但是经过彻底的重新格式化和新的 ubuntu 14.04 我让它运行了:

Following these instructions (http://bendemott.blogspot.de/2013/11/installing-pylucene-4-451.html) got my system installed with pylucene. Before it was working, it was crazy and I had this problem (Building Pylucene on ubuntu 14.04(trusty tahr)) but after a thorough reformatting and a fresh ubuntu 14.04 i got it running:

# Downloads and extract pylucene
$ wget http://mirror.serversupportforum.de/apache/lucene/pylucene/pylucene-4.9.0-0-src.tar.gz
$ tar -zxvf pylucene-4.9.0-0-src.tar.gz

# Install dependencies
$ sudo apt-get install ant
$ sudo apt-get install g++
$ sudo apt-get install python-dev
$ sudo apt-get install python3-setuptools
$ sudo easy_install pip
$ sudo pip install setuptools --upgrade 

# Build and install pylucene
$ cd pylucene-4.9.0-0/jcc
$ sudo python setup.py build
$ sudo python setup.py install 
$ cd ..

编辑位于您刚刚提取的pylucene-4.9.0目录根目录下的名为Makefile"的文件并找到这一行:

Edit the file named "Makefile" located at the root of the pylucene-4.9.0 directory you just extracted and locate this line:

# Linux     (Ubuntu 11.10 64-bit, Python 2.7.2, OpenJDK 1.7, setuptools 0.6.16)

如图所示取消 Makefile 中的注释行(如果您使用的是 linux)并保存更改:

Uncomment lines in the Makefile as shown (if you are on linux) and save the changes:

然后继续:

$ make 
$ sudo make install  

瞧,它已安装.测试 pylucene 是否有效:

Voila, it's installed. To test that pylucene works:

$ python
>>> import lucene
>>> lucene.initVM()

这篇关于在 ubuntu 14.04(trusty tahr) 上构建 Pylucene的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 ubuntu 14.04(trusty tahr) 上构建 Pylucene

基础教程推荐