【原创】pyopenjtalk 安装方法 100%有效

关于pyopenjtalk的安装,网上虽然有很多教程,其中绝大部分都是纯纯灌水的垃圾,除了浪费时间,完全解决不了问题,总之这篇教程希望能够帮到你。

首先这个包并没有限制python版本,尽管选择自己常用的python版本就好,例如下面3.11的python也能正常安装。
在这里插入图片描述

下面以python 3.9为例演示一下安装过程

1.首先创建一个新的环境,GUI或者命令行都行

conda create -n pyopenjtalk_test_env python=3.9.18

创建好的新环境如下,然后再别动
在这里插入图片描述

2.安装VisualStudio 2017

我只测试过这个版本是可用的,2022会在编译中报错,例如

      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 'E:\\Program Files\\Microsoft VisualStudio\\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
      [end f output]

还有这种

Using cached tqdm-4.66.1-py3-none-any.whl (78 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
  ╰─> [152 lines of output]
      fatal: not a git repository (or any of the parent directories): .git
      CMake is in the system path. Version:               cmake version 3.27.5

      CMake suite maintained and supported by Kitware (kitware.com/cmake).

微软官方下载地址:https://visualstudio.microsoft.com/zh-hans/vs/older-downloads/
选第一个就行
在这里插入图片描述
在安装界面勾选使用C++的桌面开发,可选项跟着图中的选,不一定非要装C盘,这里我选的E
在这里插入图片描述
安装完成后,在系统环境变量中加入下面两条
E:\改成你自己安装VS的位置\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin
E:\改成你自己安装VS的位置\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64

下一步,打开终端控制台,输入cmake查看是否有下面的回应

 C:\Users\Administrator>cmake
 
Usage
 cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

出现这个表示cmake配置正确

3 在控制台中激活刚刚创建的环境

conda activate pyopenjtalk_test_env

如果conda activate没法用的,可以输入

conda init

试一下,或者参考这篇

Windows PowerShell中成功进入conda虚拟环境

进入环境后输入 pip install pyopenjtalk即可

(pyopenjtalk_test_env) PS C:\Users\Administrator> pip install pyopenjtalk
Collecting pyopenjtalk
  Using cached pyopenjtalk-0.3.2.tar.gz (1.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy>=1.20.0 (from pyopenjtalk)
  Obtaining dependency information for numpy>=1.20.0 from https://files.pythonhosted.org/packages/97/43/4cd9dc8c051537ed0613fcfc4229dfb9eb39fe058c8d42632977465bfdb5/numpy-1.26.0-cp39-cp39-win_amd64.whl.metadata
  Using cached numpy-1.26.0-cp39-cp39-win_amd64.whl.metadata (61 kB)
Collecting six (from pyopenjtalk)
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting tqdm (from pyopenjtalk)
  Obtaining dependency information for tqdm from https://files.pythonhosted.org/packages/00/e5/f12a80907d0884e6dff9c16d0c0114d81b8cd07dc3ae54c5e962cc83037e/tqdm-4.66.1-py3-none-any.whl.metadata
  Using cached tqdm-4.66.1-py3-none-any.whl.metadata (57 kB)
Collecting colorama (from tqdm->pyopenjtalk)
  Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Using cached numpy-1.26.0-cp39-cp39-win_amd64.whl (15.8 MB)
Using cached tqdm-4.66.1-py3-none-any.whl (78 kB)
Building wheels for collected packages: pyopenjtalk
  Building wheel for pyopenjtalk (pyproject.toml) ... done
  Created wheel for pyopenjtalk: filename=pyopenjtalk-0.3.2-cp39-cp39-win_amd64.whl size=924465 sha256=3a8572be13375945703382b013ab513966068c149f65892f4b263c7c5f7bc0a0
  Stored in directory: c:\users\administrator\appdata\local\pip\cache\wheels\3a\8b\36\272dd1c342ae05c6c0031487341623c7634b7171f492379f7a
Successfully built pyopenjtalk
Installing collected packages: six, numpy, colorama, tqdm, pyopenjtalk
Successfully installed colorama-0.4.6 numpy-1.26.0 pyopenjtalk-0.3.2 six-1.16.0 tqdm-4.66.1

安装成功!

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值