背景:
在ubuntu22.04 python3.12下,已安装pytorch的torch=2.2+cu=12.1的环境下,pip安装sentencepiece默认版本(0.1.99)始终不成功,错误提示大概是:
error:subprocess-exited-with-error
python setup.py bdist_wheel did not run successfully
exit code:1
......
ERROR: Failed building wheel for sentencepiece
分析与解决:
直观感受就是wheel文件用pip安装不成功,因为没build成功,那就本地build一下呗
sentencepiece在pypi的页面:sentencepiece · PyPI
直接按照官方指导来:
% git clone https://github.com/google/sentencepiece.git
% cd sentencepiece
% mkdir build
% cd build
% cmake .. -DSPM_ENABLE_SHARED=OFF -DCMAKE_INSTALL_PREFIX=./root
% make install
% cd ../python
% python setup.py bdist_wheel
% pip install dist/sentencepiece*.whl
build、make、setup.py
最终pip install成功