GPT-SoVITS icon indicating copy to clipboard operation
GPT-SoVITS copied to clipboard

Mac pyopenjtalk 编译错误

Open shanghailiwei opened this issue 11 months ago • 1 comments

ecab -I/Users/liwei/miniconda3/envs/GPTSoVits/include/python3.9 -c lib/open_jtalk/src/mecab/src/char_property.cpp -o build/temp.macosx-11.1-arm64-3.9/lib/open_jtalk/src/mecab/src/char_property.o In file included from lib/open_jtalk/src/mecab/src/char_property.cpp:11: In file included from lib/open_jtalk/src/mecab/src/char_property.h:8: In file included from lib/open_jtalk/src/mecab/src/mmap.h:51: 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:215:48: note: expanded from macro '__deprecated_msg' 215 | #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]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pyopenjtalk Failed to build pyopenjtalk ERROR: Could not build wheels for pyopenjtalk, which is required to install pyproject.toml-based projects

您遇到的问题是在尝试安装 pyopenjtalk 时,编译过程中出现了错误。这个错误主要是由于在编译 open_jtalk 源代码时,使用了在 C++17 标准中不再允许使用的 register 关键字,以及使用了不推荐的 sprintf 函数。

解决这个问题可能需要修改源代码,但这通常不是最佳选择,尤其是如果您不熟悉 C++。但在这种情况下,您可能没有其他选择,因为错误直接来自于第三方库的代码。

然而,这里有几个可能的解决步骤,您可以尝试:

  1. 更新您的环境:确保您的所有工具和库都是最新的,这包括 Python、pip、setuptools、wheel 以及您的 C++ 编译器。

  2. 安装依赖:确保您安装了所有 pyopenjtalk 的依赖项。有时候,错误可能是因为缺少必要的依赖项。

  3. 手动安装 Open JTalk:尝试手动编译并安装 Open JTalk,然后再次尝试安装 pyopenjtalk

  4. 修改源代码:如果您熟悉 C++,您可以尝试从 pyopenjtalk 的源代码中删除 register 关键字,并将 sprintf 替换为 snprintf。然后,您可以从修改后的源代码手动编译 pyopenjtalk

  5. 使用 Docker 或虚拟环境:如果您不能在您的本地环境中解决这个问题,使用 Docker 或另一个虚拟环境,可能预装了所有必要的依赖和配置,可以作为一个解决方案。

  6. 寻求 pyopenjtalk 的替代品:如果 pyopenjtalk 对您的项目不是绝对必要的,您可以考虑寻找替代的库或工具。

如果您决定修改源代码,请记得备份原始文件。这些修改可能会破坏源代码的兼容性,或使未来的更新更加困难。如果您对如何进行这些修改不确定,最好是寻求一个更有经验的开发者的帮助或直接联系 pyopenjtalk 的维护者。

shanghailiwei avatar Feb 27 '24 07:02 shanghailiwei

尝试运行 pip install --upgrade pip 后再安装试试

Lion-Wu avatar Feb 28 '24 15:02 Lion-Wu

谢谢Lion-wu, 后来发现是我的cc编译的版本过高, 降级到14的版本就可以了。

shanghailiwei avatar Mar 01 '24 08:03 shanghailiwei