Search code examples
pythonmingw-w64pyaudioportaudiomsys

Install pyaudio on MSYS2 (broken c files)


i am trying to install pyaudio python module in MSYS2/MingGW64 on a new machine.

Χρήστος Παππάς@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

I have installed portaudio via pacman command: pacman -S mingw-w64-x86_64-portaudio

I have put ffmpeg exe files (maybe) in /usr/bin. I think is something wrong with version of gcc.

How can I install python pyaudio module in Windows 10 (msys2 mingw64)?

In the past i have sucessfully installed that module in another computer but i have not the instructions now, so it can be. Should I install Microsoft Visual C++ Redistridutable? Is that necessary?


Solution

  • Step for install pyaudio module in msys2 mingw64 enviroment.

    1. Download pyaudio from github
    2. Download portaudio
    3. Put portaudio inside pyaudio project folder
    4. Run pacman -S mingw-w64-x86_64-portaudio
    5. Run PATH=/C/msys64/mingw64/bin where C:\msys64\mingw64\bin the folder that contains gcc.exe. If you have not installed gcc you can run: pacman -S gcc
    6. Go to pyaudio project and run python setup.py build_ext --inplace and finally run:
    7. python setup.py install

    That's it! The python module will be sucessfully installed to msys platform. I don't know if all the up instructions are necessary but now works!