安装pysptk出错

###### python环境安装pysptk不成功,尝试了多个python版本,从3.53.10。

###### pip install pysptk

######  cl: 命令行 warning D9002 :忽略未知选项“-std=c99”
  swipe.c
  lib\SPTK\bin\pitch\swipe\swipe.c(115): warning C4273: “log2”: dll 链接不一致
  lib\SPTK\bin\pitch\swipe\swipe.c(115): note: 参见“log2”的前一个定义
  lib\SPTK\bin\pitch\swipe\swipe.c(115): error C2169: “log2”: 内部函数,不能定义
  lib\SPTK\bin\pitch\swipe\swipe.c(122): warning C4273: “round”: dll 链接不一致
............中间省略.......................
 error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.32.31326\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for pysptk
Failed to build pysptk
ERROR: Could not build wheels for pysptk which use PEP 517 and cannot be installed directly
(singmix35) C:\Users\DELL>pip install pysptk


###### 应该是环境问题,有安装成功的朋友可否告知你们的python版本?

###### 能够成功安装pysptk

你的错误是由于编译器引起的,windows中visual stuido中是微软的cl编译器,和gcc/g++有区别。报错内容显示cl对于log2有额外定义,和代码中冲突。
解决办法是在你的windows上安装mingw,然后在mingw中使用gcc安装这个包

这里有一个类似的介绍https://pypi.org/project/swigibpy/#:~:text=To%20get%20pip%20to%20use%20MinGW%20as%20the,and%20with%20a%20bit%20of%20luck%2C%20you%E2%80%99re%20done%21

另外windows的cl编译器是没有--std这种写法的,你可以查询微软doc的CL option,https://docs.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-alphabetically?view=msvc-170

log2https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/log2-log2f-log2l?view=msvc-170,只要用windows的编译器cl,是不可避免会报错 所以你即便更换版本也毫无用处

更新pip 和 setuptools再进行安装

setup.py中在哪里指定一定要用cl编译呢?用其它的编译可以吗?在哪里指定呢?

使用命令:

pip3 install pysptk -i https://pypi.tuna.tsinghua.edu.cn/simple

能够安装成功

img

python 版本:3.8

img

如有帮助,望采纳!

我一般是先conda,在conda下安装一个虚拟环境,再安装包基本没啥问题。
1.windows安装anaconda

2.安装虚拟环境以及conda操作教程:
https://blog.csdn.net/u010212101/article/details/103351853