【问题标题】:ImportError: cannot import name Library, during installing PyLuceneImportError:在安装 PyLucene 期间无法导入名称库
【发布时间】:2013-10-19 05:49:29
【问题描述】:

我已经花了 5 个小时来解决这个问题,但我不能。在使用 http://lucene.apache.org/pylucene/install.htmt 安装 PyLucene 时,我遇到了如下错误。

sanghee-m:jcc sanghee$ python setup.py build
found JAVAFRAMEWORKS = /System/Library/Frameworks/JavaVM.framework
Traceback (most recent call last):
  File "setup.py", line 398, in <module>
    main('--debug' in sys.argv)
  File "setup.py", line 306, in main
    from setuptools import Library
ImportError: cannot import name Library
sanghee-m:jcc sanghee$ python setup.py build --debug
found JAVAFRAMEWORKS = /System/Library/Frameworks/JavaVM.framework
Traceback (most recent call last):
  File "setup.py", line 398, in <module>
    main('--debug' in sys.argv)
  File "setup.py", line 306, in main
    from setuptools import Library
ImportError: cannot import name Library
sanghee-m:jcc sanghee$ 

我也找不到图书馆。我该如何解决这个问题?当我收到此类错误时,您能告诉我应该在哪里检查吗?

另外,我安装了 setuptools 1.1.6 并使用了 pylucene-4.4.0-1。

sanghee-m:jcc sanghee$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools

【问题讨论】:

标签: python python-2.7 pylucene


【解决方案1】:

我尝试在windows下编译JCC,发现最新版的setuptools,1.1.6,出现了你报的导入错误。但是在 0.6c11 版本中可以找到库模块。

编辑:1.1.3 也可以。

【讨论】:

    【解决方案2】:

    这似乎是一个愚蠢的问题,但您是否安装了 setuptools? https://pypi.python.org/pypi/setuptools/0.6c11

    【讨论】:

    • 是的!我安装了 setuptools。
    • 你在 Windows 上吗?也许这是一个路径问题? from setuptools import Library 从解释器中工作吗?
    • 你好,一开始是路径问题,后来setuptools 1.1.6没有Library所以我用setuptools 0.x代替1.1.6就可以了!