MacOS 安装时遇到pyopenjtalk编译失败的解决办法
问题在于Xcode 15.0按照 C++ 20的标准进行编译,导致代码失败。
解决方法是
首先激活虚拟环境 然后
git clone https://github.com/r9y9/pyopenjtalk/
然后按照这个 PR 修改clone下来的项目中的文件
接着
pip install Cython
pip install numpy
最后在pyopenjtalk 的根目录使用 python setup.py install
此时pyopenjtalk就安装好了
I found that "pip install pyopenjtalk" cannot use the clang installed by homebrew, instead we can use gcc lib/open_jtalk/src/mecab/src/utils.h:47:8: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations] 47 | std::sprintf(s, "%-16f", val); | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/stdio.h:180:1: note: 'sprintf' has been explicitly marked deprecated here 180 | __deprecated_msg("This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.") | ^ /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/sys/cdefs.h:218:48: note: expanded from macro '__deprecated_msg' 218 | #define __deprecated_msg(_msg) attribute((deprecated(_msg))) | ^ In file included from lib/open_jtalk/src/mecab/src/char_property.cpp:11: lib/open_jtalk/src/mecab/src/char_property.h:40:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 40 | register const char *p = begin; | ^~~~~~~~ 1 warning and 1 error generated. error: command '/opt/homebrew/opt/llvm/bin/clang' failed with exit code 1 [end of output]