已复制
全屏展示
复制代码

总结pyopenjtalk安装问题

· 4 min read

源项目地址 https://huggingface.co/spaces/skytnt/moe-tts ,它是一个文字转语音的项目,在huggingface上有性能限制,我想把它git clone安装到我本地的windows上,在安装依赖的过程中出现了 pyopenjtalk 依赖安装报错。

问题说明

我的系统是windows11 专业版,在安装依赖时, pyopenjtalk 是出现下面问题:

Collecting tqdm (from pyopenjtalk)
  Using cached https://mirrors.aliyun.com/pypi/packages/00/e5/f12a80907d0884e6dff9c16d0c0114d81b8cd07dc3ae54c5e962cc83037e/tqdm-4.66.1-py3-none-any.whl (78 kB)
Collecting colorama (from tqdm->pyopenjtalk)
  Using cached https://mirrors.aliyun.com/pypi/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Building wheels for collected packages: pyopenjtalk
  Building wheel for pyopenjtalk (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pyopenjtalk (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [154 lines of output]
      setup.py:26: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        _CYTHON_INSTALLED = ver >= LooseVersion(min_cython_ver)
      fatal: not a git repository (or any of the parent directories): .git
      CMake is in the system path. Version:               cmake version 3.27.7

      CMake suite maintained and supported by Kitware (kitware.com/cmake).
      running bdist_wheel
      running build
      running build_py
      -- Building version 0.3.2
      ........
      ........
      ........
      ........
      ........
      C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\include\map(25): note: 参见“std”的声明
      lib\open_jtalk\src\mecab/src\dictionary.cpp(466): note: 查看对正在编译的 类 模板 实例化“MeCab::`anonymous-namespace'::pair_1st_cmp<std::string,MeCab::Token *>”的引用
      lib\open_jtalk\src\mecab/src\dictionary.cpp(68): error C2504: “binary_function”: 未定义基类
      lib\open_jtalk\src\mecab/src\dictionary.cpp(479): warning C4267: “参数”: 从“size_t”转换到“_Ty”,可能丢失数据
              with
              [
                  _Ty=int
              ]
      lib\open_jtalk\src\mecab/src\dictionary.cpp(489): warning C4267: “参数”: 从“size_t”转换到“_Ty”,可能丢失数据
              with
              [
                  _Ty=int
              ]
      lib\open_jtalk\src\mecab/src\dictionary.cpp(515): warning C4267: “初始化”: 从“size_t”转换到“unsigned int”,可能丢 失数据
      lib\open_jtalk\src\mecab/src\dictionary.cpp(516): warning C4267: “初始化”: 从“size_t”转换到“unsigned int”,可能丢 失数据
      lib\open_jtalk\src\mecab/src\dictionary.cpp(517): warning C4267: “初始化”: 从“size_t”转换到“unsigned int”,可能丢 失数据
      lib\open_jtalk\src\mecab/src\dictionary.cpp(518): warning C4267: “初始化”: 从“size_t”转换到“unsigned int”,可能丢 失数据
      lib\open_jtalk\src\mecab/src\dictionary.cpp(519): warning C4267: “初始化”: 从“size_t”转换到“unsigned int”,可能丢 失数据
      lib\open_jtalk\src\mecab/src\dictionary.cpp(524): warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [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

尝试解决1

搜索网上的教程,添加了两个环境变量,我的visual studio 是2022版本的,环境变量如下:


C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\Hostx86\x64

添加环境变量以后还报错

尝试解决2

看到有人遇到相同的问题,解决方是使用2017版的visual studio,于是我下载 2017 版 https://my.visualstudio.com/Downloads?q=visual studio 2017

安装以后,把环境变量改成2017的,重新创建虚拟环境安装


conda create -n moe-tts python=3.10
conda activate moe-tts

pip install pyopenjtalk

添加环境变量

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x64

查看安装命令是否正确

还是报相同错。仔细观察报错,在报错的最后有一个提示:


error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]
      

从这个提示说明我使用的工具还是visual studio 2022的并不是2017的,然后有尝试重启机器还是不行。

最后在chatgpt的提示下,它让我直接打开2017的开发控制台来安装发现居然安装成功了:C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2017\Visual Studio Tools\VC

使用2017的控制台就不会报错了

参考文档:

🔗