[python] 2、python使用pyaudio进行录音,及其在python虚拟环境virtualenv中安装遇到的问题

 

1、pyaudio安装大背景 

最近在做智能音箱,需要编写声音拾取代码,我先是百度两篇比较常见的用python进行录音的操作的文章:

python写一个录音小程序:

利用百度语言识别API实现语音识别python:

 

发现需要用到pyaudio,然后在其官网找到如何安装:

[python] 2、python使用pyaudio进行录音,及其在python虚拟环境virtualenv中安装遇到的问题

 

但是,在py虚拟环境中通过pip安装会报错,而采用sudo apt-get install python-pyaudio python3-pyaudio安装没有报错,但是在虚拟环境中不行。

注:全局安装不适用于python虚拟环境中,python虚拟环境和全局环境互不影响。

 

2、解决python虚拟环境中安装pyaudio走过的坑

坑一:utbutu16.10 安装pyaudio模块过程出现错误 fatal error: portaudio.h: 没有那个文件或目录 error: command 'x86_64-linux-gn

尝试,发现没用

 

坑二:安装pyaudio找不到portaudio.h的问题

尝试,发现无用

[python] 2、python使用pyaudio进行录音,及其在python虚拟环境virtualenv中安装遇到的问题

[python] 2、python使用pyaudio进行录音,及其在python虚拟环境virtualenv中安装遇到的问题

1 ➜ ~ sudo apt-get install portaudio19-dev python-all-dev python3-all-dev 2 Reading package lists... Done 3 Building dependency tree 4 Reading state information... Done 5 python-all-dev is already the newest version (2.7.14-2ubuntu1). 6 The following additional packages will be installed: 7 jackd1 jackd1-firewire libasound2-dev libjack-dev libjack0 libportaudiocpp0 libpython3-all-dev libzita-alsa-pcmi0 libzita-resampler1 python3-all uuid-dev 8 Suggested packages: 9 jack-tools meterbridge libasound2-doc portaudio19-doc 10 The following packages will be REMOVED: 11 jackd2 jackd2-firewire libjack-jackd2-0 12 The following NEW packages will be installed: 13 jackd1 jackd1-firewire libasound2-dev libjack-dev libjack0 libportaudiocpp0 libpython3-all-dev libzita-alsa-pcmi0 libzita-resampler1 portaudio19-dev python3-all python3-all-dev uuid-dev 14 0 upgraded, 13 newly installed, 3 to remove and 5 not upgraded. 15 Need to get 0 B/798 kB of archives. 16 After this operation, 2,595 kB of additional disk space will be used. 17 Do you want to continue? [Y/n] Y 18 Preconfiguring packages ... 19 dpkg: warning: files list file for package 'emacsen-common' missing; assuming package has no files currently installed 20 (Reading database ... 419524 files and directories currently installed.) 21 Removing jackd2-firewire (1.9.10+20150825git1ed50c92~dfsg-5ubuntu1) ... 22 dpkg: jackd2: dependency problems, but removing anyway as you requested: 23 jackd depends on jackd2 | jackd1; however: 24 Package jackd2 is to be removed. 25 Package jackd1 is not installed. 26 27 Removing jackd2 (1.9.10+20150825git1ed50c92~dfsg-5ubuntu1) ... 28 dpkg: warning: files list file for package 'emacsen-common' missing; assuming package has no files currently installed 29 (Reading database ... 419435 files and directories currently installed.) 30 Preparing to unpack .../jackd1_1%3a0.125.0-2_amd64.deb ... 31 Unpacking jackd1 (1:0.125.0-2) ... 32 dpkg: error processing archive /var/cache/apt/archives/jackd1_1%3a0.125.0-2_amd64.deb (--unpack): 33 trying to overwrite '/usr/lib/x86_64-linux-gnu/libjackserver.so.0', which is also in package libjack-jackd2-0:amd64 1.9.10+20150825git1ed50c92~dfsg-5ubuntu1 34 Errors were encountered while processing: 35 /var/cache/apt/archives/jackd1_1%3a0.125.0-2_amd64.deb 36 E: Sub-process /usr/bin/dpkg returned an error code (1) 37 ➜ ~

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwgfyz.html