【问题记录】ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based..

问题:pip install pyaudio 时报错如下

Collecting pyaudio
  Using cached PyAudio-0.2.12.tar.gz (42 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
  Building wheel for pyaudio (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for pyaudio (pyproject.toml) did not run successfully.exit code: 1
  ╰─> [16 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-37
      copying src/pyaudio.py -> build/lib.linux-x86_64-cpython-37
      running build_ext
      building '_portaudio' extension
      creating build/temp.linux-x86_64-cpython-37
      creating build/temp.linux-x86_64-cpython-37/src
      gcc -pthread -B /home/dreamdeck/anaconda3/envs/audio2face/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/include -I/home/dreamdeck/anaconda3/envs/audio2face/include/python3.7m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-cpython-37/src/_portaudiomodule.o
      src/_portaudiomodule.c:31:10: fatal error: portaudio.h: No such file or directory
       #include "portaudio.h"
                ^~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects

一、从源安装包解决

sudo apt-get install portaudio19-dev
pip install pyaudio

二、手动解决

但无法从源来安装包时,可以下载包来解决

wget http://www.portaudio.com/archives/pa_stable_v190600_20161030.tgz
tar -zxvf pa_stable_v190600_20161030.tgz 
cd portaudio/
./configure && make && sudo make install 
pip install pyaudio

你可能感兴趣的:(问题记录,python)