导入错误:没有名为 _jcc 的模块

发布于 2024-09-17 07:35:42 字数 408 浏览 5 评论 0原文

四天以来我一直在尝试在 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  

有什么想法吗?它看起来安装完美,但我无法导入它。

I'm trying to install pylucene on python 2.7 (windows) since four days. It requires JCC to build and install. After thousands and thousands different errors I handled myself, at last JCC sucessfully builded and installed. At least, that was what I thought. After that, I tried to import jcc but I get this error:

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  

any ideas? It looks installed perfectly but I can't import it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

拥有 2024-09-24 07:35:42

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

Make sure your current dir is not jcc build directory. I get this error if I try to import jcc when in build directory, python uses the wrong jcc then.

时光倒影 2024-09-24 07:35:42

这将很难回答,因为有太多的依赖关系,为了给这个问题提供足够的上下文,你几乎必须向我们运送你的机器。

有一些问题想问你;通过编辑您的原始问题可以最好地回答哪些问题:

  1. 这只是关于 JCC 错误? pylucene 是目标,但不是问题的一部分?
  2. 您自己处理过哪些数千个错误?不,我不需要 1000 个答案,我想知道为什么对于受支持的平台来说如此困难。
  3. 您想要构建什么版本的 JCC?

作为一个大胆的猜测,JCC 安装说明 中的这一行看起来像它可能非常相关:

必须将包含必要 DLL 的 Java 目录添加到 PATH 中。

添加以回应评论:

您已经让自己陷入了依赖地狱,远程答案几乎是不可能的。只需查看您必须列出来描述工作的修订的绝对数量,您就可以了解需要协调多少事情。

不幸的是,我自己也经历过几次,这就是为什么我现在尽我所能来最大程度地减少“刚刚出测试版”版本软件堆栈的数量。

在 Ubuntu Lucid 上,我能够

$ 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', ...

但是那是去年的 PyLucene 在去年的 Python 上运行。而且我不了解 lucene,所以我什至无法确认最小的操作,但假设它是一个有效的 PyLucene 2.3.1。

祝你好运;你可能会发现,如果你想让它正常工作并保持理智,你需要放松你的要求。

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.

黑白记忆 2024-09-24 07:35:42

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

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

很快就会有更多鸡蛋出现,或者如果您设法让它发挥作用,请随时贡献力量。

Building pylucene has been a major pain for me too. You may want to have a look at http://code.google.com/a/apache-extras.org/p/pylucene-extra/ - we just started it, and many people seem to have the same issues with the insanely complex build.

The goal is to provide pylucene as pre-built eggs on several operating systems, Python versions and Java runtimes combos.

More eggs will come soon, or please feel free to contribute if you managed to get it working.

花桑 2024-09-24 07:35:42

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

  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. 安装JCC easy_install JCC-2.8-py2.7-win32.egg

  6. < p>安装 PyLucene easy_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 ->首选项 打开首选项对话框。
    • 更改为PyDev ->解释器 - 用于配置 Python 的 Python 部分。
    • 单击新建文件夹,选择2 个新鸡蛋。 Pylucene 和 JCC 位于 c:\Pyton27\Lib\Site-packages\Lucene Etc 和 JCC-Etc。

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

I suggest using a pre-built one: Here is the combination that worked for me.

  1. Download JDK 1.6.0_26

  2. Download: lucene-3.1.0-py2.7-win32.egg

  3. Download JCC JCC-2.8-py2.7-win32.egg

  4. Install Java JRE or Java JDK, add C:\Program Files\Java\jdk1.6.0_03\jre\bin\client\ to your path;

  5. Install JCC easy_install JCC-2.8-py2.7-win32.egg

  6. Install PyLucene easy_install lucene-3.1.0-py2.7-win32.egg

  7. Add C:\Python27\Lib\site-packages\JCC-2.8-py2.7-win32.egg\jcc.dll to your path

  8. Test that it is working in the command line python 2.7: python -m jcc

  9. Configure Eclipse IDE to ensure it picks up new libraries.
    • After Eclipse restarts:
    • Choose Windows -> Preferences to bring up the preferences dialog.
    • Change to the PyDev -> Interpreter - Python section to configure Python.
    • Click on New folder select the 2 new eggs. Pylucene and JCC in c:\Pyton27\Lib\Site-packages\Lucene Etc and JCC- Etc.

By the way when I ported the above which was working using Django Dev server to Apache and Mod_WSGI it no longer worked and I get the same error you got. I ended up successfully using Solr with Sunburnt, which I think is a more scalable solution that works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文