我在运行python文件时遇到问题,该文件导入了enchant库。我用以下命令安装了enchant模块:
$ pip install -U pyenchant
> Requirement already up-to-date: pyenchant in /usr/lib/python3.4/site-packages
$ cat ~/diskchall.py
import enchant
dictionary = enchant.Dict("en_US")
...
$ py ~/diskchall.py
Traceback (most recent call last):
File "/root/diskchall.py", line 1, in <module>
import enchant
File "/usr/lib/python3.4/site-packages/enchant/__init__.py", line 92, in <module>
from enchant import _enchant as _e
File "/usr/lib/python3.4/site-packages/enchant/_enchant.py", line 143, in <module>
raise ImportError(msg)
ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI.
在El Capitan上执行了几乎相同的步骤,但运行时出现了一个输入错误。在
根据this issue的建议,通过更改_enchant.py
文件进行修复。在
非常遗憾的是,这一承诺来自2014年的。在
看起来你至少缺少了一个依赖项“enchant”C库。它或者叫做libenchant或者enchant。python模块是这个库的包装器,所以您需要这个库来使用包装器。 要查看可用的内容,请尝试:
你的命令
^{pr2}$不会显示python附魔,因为您安装了pip not yum。相反,请尝试:
可以看到一个python enchant构建的依赖项列表here注意enchant>;=1.5.0的要求(有时称为libenchant)
在RedHat上,一个简单的“yum whatprovides enchant”就可以:
安装时:
如果您有Python2.7和Centos 7(任何次要版本),这些是安装和运行enchant库的步骤。 1安装适用于centos7的epel版本,遵循enchant的其他依赖项。在
这将安装pyenchant库和拼写检查器for EN(您可以相应地更改为任何其他语言)和PY和hunspeller的aspell接口。在
相关问题 更多 >
编程相关推荐