在 MSYS2 上安装 pyaudio(损坏的 c 文件)
Posted
技术标签:
【中文标题】在 MSYS2 上安装 pyaudio(损坏的 c 文件)【英文标题】:Install pyaudio on MSYS2 (broken c files) 【发布时间】:2021-11-03 15:22:52 【问题描述】:我正在尝试在新机器上安装 MSYS2/MingGW64 中的 pyaudio python 模块。
Χρήστος Παππάς@DESKTOP-8T1C1VF MSYS /c/Users/Χρήστος Παππάς/Documents/projects/Papinhio player/Αρχεία πηγαίου κώδικα εφαρμογής (python)
$ cd ../Σημειώσεις\ και\ βιβλιοθήκες\ \(notes\)/
Χρήστος Παππάς@DESKTOP-8T1C1VF MSYS /c/Users/Χρήστος Παππάς/Documents/projects/Papinhio player/Σημειώσεις και βιβλιοθήκες (notes)
$ cd PyAudio-0.2.11/
Χρήστος Παππάς@DESKTOP-8T1C1VF MSYS /c/Users/Χρήστος Παππάς/Documents/projects/Papinhio player/Σημειώσεις και βιβλιοθήκες (notes)/PyAudio-0.2.11
$ python setup.py build
running build
running build_py
running build_ext
building '_portaudio' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -march=x86-64 -mtune=generic -O2 -pipe -march=x86-64 -mtune=generic -O2 -pipe -I/usr/include/python3.9 -c src/_portaudiomodule.c -o build/temp.msys-3.2.0-x86_64-3.9/src/_portaudiomodule.o
In file included from src/_portaudiomodule.c:27:
/usr/local/include/stdio.h:1258:18: error: expected ‘,’ or ‘;’ before ‘fgetwc’
1258 | wint_t __cdecl fgetwc(FILE *_File);
| ^~~~~~
/usr/local/include/stdio.h:1259:26: error: expected ‘,’ or ‘;’ before ‘_fgetwchar’
1259 | _CRTIMP wint_t __cdecl _fgetwchar(void);
| ^~~~~~~~~~
/usr/local/include/stdio.h:1260:18: error: expected ‘,’ or ‘;’ before ‘fputwc’
1260 | wint_t __cdecl fputwc(wchar_t _Ch,FILE *_File);
| ^~~~~~
/usr/local/include/stdio.h:1261:26: error: expected ‘,’ or ‘;’ before ‘_fputwchar’
1261 | _CRTIMP wint_t __cdecl _fputwchar(wchar_t _Ch);
| ^~~~~~~~~~
/usr/local/include/stdio.h:1262:18: error: expected ‘,’ or ‘;’ before ‘getwc’
1262 | wint_t __cdecl getwc(FILE *_File);
| ^~~~~
/usr/local/include/stdio.h:1263:18: error: expected ‘,’ or ‘;’ before ‘getwchar’
1263 | wint_t __cdecl getwchar(void);
| ^~~~~~~~
/usr/local/include/stdio.h:1264:18: error: expected ‘,’ or ‘;’ before ‘putwc’
1264 | wint_t __cdecl putwc(wchar_t _Ch,FILE *_File);
| ^~~~~
/usr/local/include/stdio.h:1265:18: error: expected ‘,’ or ‘;’ before ‘putwchar’
1265 | wint_t __cdecl putwchar(wchar_t _Ch);
| ^~~~~~~~
/usr/local/include/stdio.h:1266:18: error: expected ‘,’ or ‘;’ before ‘ungetwc’
1266 | wint_t __cdecl ungetwc(wint_t _Ch,FILE *_File);
| ^~~~~~~
In file included from src/_portaudiomodule.c:27:
/usr/local/include/stdio.h:1516:28: error: expected ‘,’ or ‘;’ before ‘_wspawnl’
1516 | _CRTIMP intptr_t __cdecl _wspawnl(int _Mode,const wchar_t *_Filename,const wchar_t *_ArgList,...);
| ^~~~~~~~
/usr/local/include/stdio.h:1517:28: error: expected ‘,’ or ‘;’ before ‘_wspawnle’
1517 | _CRTIMP intptr_t __cdecl _wspawnle(int _Mode,const wchar_t *_Filename,const wchar_t *_ArgList,...);
| ^~~~~~~~~
/usr/local/include/stdio.h:1518:28: error: expected ‘,’ or ‘;’ before ‘_wspawnlp’
1518 | _CRTIMP intptr_t __cdecl _wspawnlp(int _Mode,const wchar_t *_Filename,const wchar_t *_ArgList,...);
| ^~~~~~~~~
/usr/local/include/stdio.h:1519:28: error: expected ‘,’ or ‘;’ before ‘_wspawnlpe’
1519 | _CRTIMP intptr_t __cdecl _wspawnlpe(int _Mode,const wchar_t *_Filename,const wchar_t *_ArgList,...);
| ^~~~~~~~~~
/usr/local/include/stdio.h:1520:28: error: expected ‘,’ or ‘;’ before ‘_wspawnv’
1520 | _CRTIMP intptr_t __cdecl _wspawnv(int _Mode,const wchar_t *_Filename,const wchar_t *const *_ArgList);
| ^~~~~~~~
/usr/local/include/stdio.h:1521:28: error: expected ‘,’ or ‘;’ before ‘_wspawnve’
1521 | _CRTIMP intptr_t __cdecl _wspawnve(int _Mode,const wchar_t *_Filename,const wchar_t *const *_ArgList,const wchar_t *const *_Env);
| ^~~~~~~~~
.
.
.
error: command '/usr/bin/gcc' failed with exit code 1
我已经通过 pacman 命令安装了 portaudio:pacman -S mingw-w64-x86_64-portaudio
我已将 ffmpeg exe 文件(可能)放在 /usr/bin 中。 我认为 gcc 的版本有问题。
如何在 Windows 10 (msys2 mingw64) 中安装 python pyaudio 模块?
过去我已经成功地在另一台计算机上安装了该模块,但我现在没有说明,所以它可以。 我应该安装 Microsoft Visual C++ Redistridutable 吗? 有必要吗?
【问题讨论】:
【参考方案1】:在 msys2 mingw64 环境中安装 pyaudio 模块的步骤。
-
下载pyaudio from github
下载portaudio
将portaudio放到pyaudio项目文件夹中
运行
pacman -S mingw-w64-x86_64-portaudio
运行 PATH=/C/msys64/mingw64/bin
其中 C:\msys64\mingw64\bin 包含 gcc.exe 的文件夹。
如果你还没有安装 gcc,你可以运行:pacman -S gcc
进入pyaudio项目并运行python setup.py build_ext --inplace
最后运行:
python setup.py install
就是这样! python模块将成功安装到msys平台。 我不知道是否所有的 up 指令都是必要的,但现在可以了!
【讨论】:
以上是关于在 MSYS2 上安装 pyaudio(损坏的 c 文件)的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 MSYS2 在 Windows 上安装 GTK3 和 minGW
如何通过cli在heroku上安装pyaudio python包
我无法在 Windows 上安装 pyaudio?如何解决“错误:需要 Microsoft Visual C++ 14.0。”?