在MSYS2上安装pyaudio(损坏的c文件)



我正在尝试在新机器上安装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++ redistributable吗?有必要吗?

在msys2mingw64环境下安装pyaudio模块的步骤。

  1. 从github下载
  2. 下载portaudio
  3. 将portaudio放入pyaudio项目文件夹
  4. 运行pacman -S mingw-w64-x86_64-portaudio
  5. 在"C:msys64mingw64bin"目录下执行PATH=/C/msys64/mingw64/bin命令。如果你没有安装gcc,你可以运行:pacman -S gcc
  6. 进入pyaudio项目,运行python setup.py build_ext --inplace,最后运行:
  7. python setup.py install

就是这样!python模块将成功安装到msys平台。我不知道是否所有的向上指令是必要的,但现在工作!

最新更新