https://github.com/vrasneur/pyfasttext/issues/51
系统环境:
- MacOS Mojave 10.14.6
- Python 3.6.8
按照 pyfasttext 给的方式安装,均出现类似的报错:
法1. pip 安装
前置依赖
pip install cython
pip install cysignals
安装
pip install pyfasttext
报错,与 gcc 相关
法2. 源码安装
cd project/venv/lib/python3.6/site-packages
git clone --recursive https://github.com/vrasneur/pyfasttext.git
cd pyfasttext
pip install -r requirements.txt
python setup.py install
报错,依然和编译器有关
解决方案
pyfasttext issues 给的解决方案,大部分是在安装时,声明 gcc 或者 g++ 的路径。
注意: mac 自带的 gcc 或 g++,位于 /usr/bin/gcc
和 /usr/bin/g++
使用 brew install / update gcc
,安装至/usr/local/bin
下:
但即使指定 CXX=/usr/local/bin/gcc-9 CC=/usr/local/bin/gcc-9
路径后,再进行安装,依然报错。
最后发现,mac 使用 clang
编译,重新更改编译路径,就可以成功安装了(两种方式都可以)。
Solution: CXX=/usr/bin/clang CC=/usr/bin/clang pip3 install --no-cache pyfasttext