问题陈述
我在运行导入附魔库的 python 文件时遇到问题。我已经使用以下命令安装了附魔模块:
$ pip install -U pyenchant
> Requirement already up-to-date: pyenchant in /usr/lib/python3.4/site-packages
我的 Python 环境
$ cat /etc/*-release
CentOS Linux release 7.2.1511 (Core)
$ cat ~/.zshrc
...
export PYTHONPATH=/usr/lib/python3.4/site-packages
alias py="python3"
alias pip="pip3"
...
$ py --version
Python 3.4.3
$ pip --version
pip 8.1.1 from /usr/lib/python3.4/site-packages (python 3.4)
$ echo $PYTHONPATH
/usr/lib/python3.4/site-packages
$ ls -al /usr/lib/python3.4/site-packages | grep enchant
drwxr-xr-x 5 root root 4096 13 apr 13:56 enchant
drwxr-xr-x 2 root root 4096 13 apr 13:56 pyenchant-1.6.6.dist-info
$ yum list installed | grep python-enchant
((nothing))
我的 Python 文件
$ 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.
OS X El Capitan - 类型错误
在 El Capitan 上做了几乎相同的步骤,但是在运行时它给了我一个 TypeError。
通过按照此问题_enchant.py
的建议更改文件来修复。
很遗憾,这个提交是从2014 年开始的,并且仍然没有进行 Pip 回购。