2

自四天以来,我一直在尝试在 python 2.7(Windows)上安装 pylucene。它需要 JCC 来构建和安装。在我自己处理了成千上万个不同的错误之后,终于成功构建和安装了 JCC。至少,我是这么认为的。之后,我尝试导入 jcc,但出现此错误:

Traceback (most recent call last):  
    File "<stdin>", line 1, in <module>  
    File "jcc\__init__.py", line 29, in <module>  
      from _jcc import initVM  
ImportError: No module named _jcc  

有任何想法吗?它看起来安装得很完美,但我无法导入它。

4

4 回答 4

3

确保您当前的目录不是 jcc 构建目录。如果我在构建目录中尝试导入 jcc,则会收到此错误,然后 python 使用错误的 jcc。

于 2011-09-06T17:32:24.510 回答
0

This is going to be tough to answer because there are so many dependencies that to give the question enough context you'd almost have to ship us your machine.

So some questions for you; which are answered best by editing your original question:

  1. This is only about JCC errors? And pylucene is the goal but not part of the problem?
  2. What sort of thousands of errors did you handle yourself? No, I don't want 1000 answers, I'm wondering why it was so difficult for a supported platform.
  3. What version of JCC are you trying to build?

As a wild guess, this line from the JCC installation instructions seems like it could be quite relevant:

Adding the Java directories containing the necessary DLLs and to PATH is a must.

Added in response to comments:

You've gotten yourself into dependency hell for which remote answers are nearly impossible. Just looking at the sheer number of revisions you have to list to describe the work should give you an idea of how many things you have to coordinate.

It's unfortunate, and I've certainly been there myself a couple of times which is why I now do whatever I can to minimize the number of "just outa beta" versions software stacks.

On Ubuntu Lucid, I was able to

$ sudo apt-get install pylucene
$ python 
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
>>> import lucene
>>> dir(lucene)
['AbstractCollection', 'AbstractField', 'AbstractList', ...

But that's last year's PyLucene running on last year's Python. And I don't know lucene so I can't even confirm minimal operation, but presume it is a working PyLucene 2.3.1.

Good luck; you may find that you need to relax your requirements if you want to get it working and remain sane.

于 2010-09-04T05:19:34.480 回答
0

我建议使用预制的:这是对我有用的组合。

  1. 下载JDK 1.6.0_26

  2. 下载:lucene-3.1.0-py2.7-win32.egg

  3. 下载JCC JCC-2.8-py2.7-win32.egg

  4. 安装 Java JRE 或 Java JDK,添加C:\Program Files\Java\jdk1.6.0_03\jre\bin\client\到你的路径;

  5. 安装 JCCeasy_install JCC-2.8-py2.7-win32.egg

  6. 安装 PyLuceneeasy_install lucene-3.1.0-py2.7-win32.egg

  7. 添加C:\Python27\Lib\site-packages\JCC-2.8-py2.7-win32.egg\jcc.dll到您的路径

  8. 测试它是否在命令行中工作python 2.7: python -m jcc

  9. 配置 Eclipse IDE 以确保它选择新的库。• Eclipse 重新启动后: • 选择Windows -> Preferences打开首选项对话框。•PyDev -> Interpreter - Python转到配置Python 部分。• 单击New folder选择2 个新鸡蛋。c:\Pyton27\Lib\Site-packages\Lucene Etc 和 JCC-Etc 中的 Pylucene 和 JCC。

顺便说一句,当我将上面使用 Django Dev 服务器的工作移植到 Apache 和 Mod_WSGI 时,它不再工作了,我得到了同样的错误。我最终成功地将 Solr 与 Sunburnt 一起使用,我认为这是一种更具可扩展性的解决方案。

于 2011-08-14T02:58:18.463 回答
0

构建 pylucene 对我来说也是一个主要的痛苦。您可能想看看http://code.google.com/a/apache-extras.org/p/pylucene-extra/ - 我们刚刚开始使用它,很多人似乎也有同样的问题复杂的构建。

目标是在多个操作系统、Python 版本和 Java 运行时组合上提供 pylucene 作为预构建的鸡蛋。

很快就会有更多的鸡蛋,或者如果你设法让它工作,请随时贡献。

于 2011-06-07T20:45:53.273 回答