Mac python pip 安装 hunspell 报错
错误信息
- ld: library not found for -lhunspell
- clang: error: linker command failed with exit code 1 (use -v to see invocation)
hunspell.cpp:20:10: fatal error: ‘hunspell.hxx’ file not found
解决
接下来是个正常安装流程,上面的错误会在下面的某一步解决掉。可以根据自己目前已经进行到哪一步进行调整,不需要一步步严格按照这个步骤来。
- 第一步
为系统安装 hunspell
brew install hunspell
- 第二步
这一步解决 下面的错误, 注意 软链的版本号
ld: library not found for -lhunspell clang: error: linker command failed with exit code 1 (use -v to see invocation)
export C_INCLUDE_PATH=/usr/local/include/hunspell
sudo ln -sf /usr/local/lib/libhunspell-1.4.a /usr/local/lib/libhunspell.a #注意版本号
- 第三步
解决 下面的错误
hunspell.cpp:20:10: fatal error: 'hunspell.hxx' file not found
git clone https://github.com/blatinier/pyhunspell.git
cd pyhunspell
vi setup.py //修改 main_module_kwargs['include_dirs’] 到个人真实环境的路径
这一步官方github的解释:
For OSX the version of the lib used to compile is hardcoded. If your installation fails, please try to clone the repo and change main_module_kwargs[‘include_dirs’] in setup.py to the correct one and/or open an issue stating the problem and the hunspell version with the .h location in your system.
- 第四步
python setup.py install
# 安装成功
>>>>
Installed /Users/tal/Workspace/venv/gec/lib/python3.7/site-packages/hunspell-0.5.5-py3.7-macosx-10.14-x86_64.egg
Processing dependencies for hunspell==0.5.5
Finished processing dependencies for hunspell==0.5.5
linux 安装报错
错误信息 : hunspell.hxx: No such file or directory
解决 : sudo apt-get install libhunspell-dev