将PyAudio升级到最新版本时出错

时间:2017-02-04 09:59:44

标签: python speech-recognition pyaudio

我的系统中安装了PyAudio (0.2.7)

当我尝试使用

升级时
sudo pip install pyaudio --upgrade

我收到了这个。

Downloading/unpacking pyaudio from https://pypi.python.org/packages/44/39/f3b9b16d32cc8588fa06bb2e813cea35363f5502117cd6cc7f619b556d9f/PyAudio-0.2.10.tar.gz#md5=b65354d997fa00a9166f8dbcb83075e6
  Downloading PyAudio-0.2.10.tar.gz (287kB): 287kB downloaded
  Running setup.py (path:/tmp/pip_build_root/pyaudio/setup.py) egg_info for package pyaudio

Installing collected packages: pyaudio
  Found existing installation: PyAudio 0.2.7
    Not uninstalling PyAudio at /usr/lib/python3/dist-packages, owned by OS


                                .......
                                .......

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.4/src/_portaudiomodule.o

src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory

 #include "portaudio.h"

                       ^

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
  Can't roll back PyAudio; was not uninstalled
Cleaning up...
Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ih3i9qsm-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/pyaudio
Storing debug log for failure in /home/jobin/.pip/pip.log

我正在使用primary os 14.04

这里有什么问题?

5 个答案:

答案 0 :(得分:8)

感谢@Cristian Ciupitu提供安装portaudio-dev的建议。

portaudio-dev在我的案例中没有安装sudo apt-get install portaudio-dev。 我得到了

E: Unable to locate package portaudio-dev 

如何解决这个问题

  1. here
  2. 下载了 .tgz 的portaudio文件
  3. 然后解压缩下载的文件。
  4. cd 到解压缩的文件夹。
  5. 然后 ./ configure&&使
  6. 现在执行 sudo make install
  7. 然后按sudo pip install pyaudio --upgrade
  8. 升级pyaudio

    现在pyaudio已成功安装。

答案 1 :(得分:1)

这对我有用

  

sudo apt-get install portaudio19-dev python-pyaudio

然后执行此操作

  

pip安装PyAudio

答案 2 :(得分:1)

在终端中运行:

  

$ sudo apt install python3-pyaudio

答案 3 :(得分:0)

您需要安装portaudio-dev软件包,例如运行:

sudo apt-get install portaudio-dev

答案 4 :(得分:-1)

pip install pyaudio --upgrade
pip install pyaudio --user