导入错误:没有名为 _jcc 的模块
四天以来我一直在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
确保您当前的目录不是 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.
这将很难回答,因为有太多的依赖关系,为了给这个问题提供足够的上下文,你几乎必须向我们运送你的机器。
有一些问题想问你;通过编辑您的原始问题可以最好地回答哪些问题:
作为一个大胆的猜测,JCC 安装说明 中的这一行看起来像它可能非常相关:
添加以回应评论:
您已经让自己陷入了依赖地狱,远程答案几乎是不可能的。只需查看您必须列出来描述工作的修订的绝对数量,您就可以了解需要协调多少事情。
不幸的是,我自己也经历过几次,这就是为什么我现在尽我所能来最大程度地减少“刚刚出测试版”版本软件堆栈的数量。
在 Ubuntu Lucid 上,我能够
但是那是去年的 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:
As a wild guess, this line from the JCC installation instructions seems like it could be quite relevant:
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
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.
构建 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.
我建议使用预先构建的组合:这是对我有用的组合。
下载 JDK 1.6.0_26
下载:lucene-3.1.0-py2.7-win32.egg
下载 JCC JCC-2.8-py2.7-win32.egg
安装Java JRE或Java JDK,添加
C:\ Program Files\Java\jdk1.6.0_03\jre\bin\client\
到你的路径;安装JCC
easy_install JCC-2.8-py2.7-win32.egg
easy_install lucene-3.1.0-py2.7-win32.egg
将
C:\Python27\Lib\site-packages\JCC-2.8-py2.7-win32.egg\jcc.dll
添加到您的路径测试它是否在命令行中工作
python 2.7 : python -m jcc
配置 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.
Download JDK 1.6.0_26
Download: lucene-3.1.0-py2.7-win32.egg
Download JCC JCC-2.8-py2.7-win32.egg
Install Java JRE or Java JDK, add
C:\Program Files\Java\jdk1.6.0_03\jre\bin\client\
to your path;Install JCC
easy_install JCC-2.8-py2.7-win32.egg
Install PyLucene
easy_install lucene-3.1.0-py2.7-win32.egg
Add
C:\Python27\Lib\site-packages\JCC-2.8-py2.7-win32.egg\jcc.dll
to your pathTest that it is working in the command line
python 2.7: python -m jcc
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.