简体   繁体   中英

Cannot install PyAudio 0.2.11 in ubuntu 16.04

I downloaded PyAudio 0.2.11 tar file from https://pypi.python.org/pypi/PyAudio and run the following command:

sudo python setup.py install

and I get the following error:

running install

Checking .pth file support in /usr/local/lib/python3.5/dist-packages/
/usr/bin/python3 -E -c pass

TEST PASSED: /usr/local/lib/python3.5/dist-packages/ appears to support .pth files

running bdist_egg

running egg_info

writing top-level names to src/PyAudio.egg-info/top_level.txt

writing src/PyAudio.egg-info/PKG-INFO

writing dependency_links to src/PyAudio.egg-info/dependency_links.txt

reading manifest file 'src/PyAudio.egg-info/SOURCES.txt'

reading manifest template 'MANIFEST.in'

writing manifest file 'src/PyAudio.egg-info/SOURCES.txt'

installing library code to build/bdist.linux-x86_64/egg

running install_lib

running build_py

running build_ext

building '_portaudio' extension

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.5/src/_portaudiomodule.o
src/_portaudiomodule.c:28:20: fatal error: Python.h: No such file or directory

compilation terminated.

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

How can I get it install successfully?

I even tried this "git clone https://people.csail.mit.edu/hubert/git/pyaudio.git " but at the time of compilation it shows the following error:

src/_portaudiomodule.c:28:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

To compile I used this command: sudo python3 setup.py install

Python The first software requirement is Python 2.6, 2.7, or Python 3.3+. This is required to use the library.

PyAudio (for microphone users) PyAudio is required if and only if you want to use microphone input (Microphone). PyAudio version 0.2.11+ is required, as earlier versions have known memory management bugs when recording from microphones in certain situations.

If not installed, everything in the library will still work, except attempting to instantiate a Microphone object will raise an AttributeError.

The installation instructions on the PyAudio website are quite good - for convenience, they are summarized below:

On Windows, install PyAudio using Pip: execute pip install pyaudio in a terminal.

On Debian-derived Linux distributions (like Ubuntu and Mint), install PyAudio using APT: execute sudo apt-get install python-pyaudio python3-pyaudio in a terminal. If the version in the repositories is too old, install the latest release using Pip: execute sudo apt-get install portaudio19-dev python-all-dev python3-all-dev && sudo pip install pyaudio (replace pip with pip3 if using Python 3).

On OS X, install PortAudio using Homebrew: brew install portaudio . Then, install PyAudio using Pip: pip install pyaudio .

On other POSIX-based systems, install the portaudio19-dev and python-all-dev (or python3-all-dev if using Python 3) packages (or their closest equivalents) using a package manager of your choice, and then install PyAudio using Pip: pip install pyaudio (replace pip with pip3 if using Python 3).

PyAudio wheel packages for common 64-bit Python versions on Windows and Linux are included for convenience, under the third-party/ directory in the repository root. To install, simply run pip install wheel followed by pip install ./third-party/WHEEL_FILENAME (replace pip with pip3 if using Python 3) in the repository root directory.

尝试了一切..对我有用的唯一方法是从https://pypi.org/project/PyAudio/#files下载文件并安装它

sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
sudo apt-get install ffmpeg libav-tools
sudo apt-get install python-pyaudio

from your terminal

这对我有用:

sudo pip install --upgrade pyaudio

you download PyAudio-0.2.11.tar.gz (md5) in https://pypi.python.org/pypi/PyAudio#downloads and extract file.

  • cd PyAudio-0.2.11

  • sudo python setup.py install

you look:

running install 
running bdist_egg
running egg_info
writing src/PyAudio.egg-info/PKG-INFO
writing top-level names to src/PyAudio.egg-info/top_level.txt
writing dependency_links to src/PyAudio.egg-info/dependency_links.txt
reading manifest file 'src/PyAudio.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'src/PyAudio.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying src/pyaudio.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/_portaudiomodule.o -lportaudio -o build/lib.linux-x86_64-2.7/_portaudio.so
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/_portaudio.so -> build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/pyaudio.py -> build/bdist.linux-x86_64/egg
byte-compiling build/bdist.linux-x86_64/egg/pyaudio.py to pyaudio.pyc
creating stub loader for _portaudio.so
byte-compiling build/bdist.linux-x86_64/egg/_portaudio.py to _portaudio.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying src/PyAudio.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/PyAudio.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/PyAudio.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/PyAudio.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/PyAudio-0.2.11-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing PyAudio-0.2.11-py2.7-linux-x86_64.egg
Copying PyAudio-0.2.11-py2.7-linux-x86_64.egg to /usr/local/lib/python2.7/dist-packages
Adding PyAudio 0.2.11 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/PyAudio-0.2.11-py2.7-linux-x86_64.egg
Processing dependencies for PyAudio==0.2.11
Finished processing dependencies for PyAudio==0.2.11

Just install with the --upgrade flag. This could be due to unsupported dependencies with the older version of PyAudio.

pip install --upgrade pyaudio

This worker for me on

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal

I too had the similar problem ,,,just upgrade ur gcc ie

sudo apt-get update gcc

install first #include<portaudio>

Try any one of these:

pip install PyAudio

pip3 install PyAudio

python -m pip install PyAudio

python -m pip3 install PyAudio

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM