How to fix installation issues for PyAudio, PortAudio: fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory
portaudio
is not a Python package, it's a C library that's entirely independent of Python, so you can't install it via pip
.
See the PortAudio for website for details on the official way to get it and install it on your platform.
AFAIK, the official way to get it on Windows is to download the source and then follow the instructions in the Tutorial for compiling it yourself. You probably want to build it with the same compiler you use for Python C extensions, although I'm not sure if that's required.
Or, if you're using a third-party package manager like Chocolatey on Windows, there's a good chance it can install PortAudio.
Or, if you use Anaconda or Miniconda for your Python, the conda
package manager knows how to install non-Python packages that Python packages depend on, including portaudio
.
Finally, there seem to be a number of people providing unofficial pre-compiled PortAudio binaries for Windows. If you search for "portaudio windows binary" or "portaudio windows pre-compiled" you'll find a number of them. I have no idea how well-tested, up-to-date, etc. any of these are.
If you're using Anaconda/Miniconda, you should have used conda install pyaudio
rather than pip install pyaudio
in the first place. You should really only use pip
for packages that aren't available on conda
or conda-forge
.
If you haven't set up conda-forge
yet, you probably want to do that first:
conda config --add channels conda-forge
And then, this should be all you need:
conda install pyaudio
Unlike the pip
package, which just assumes you have portaudio
installed properly, the conda
package will either automatically install portaudio
as a dependency for pyaudio
, or tell you why it can't.
portaudio.h: No such file or directory
This should help
$ sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio
Tested on Ubuntu 18.04
, Python 3.7.2
, pyaudio 0.2.11
Added 8th of Jan 2021:
On Ubuntu 20.04 you have to use:
$ sudo apt install portaudio19-dev python3-pyaudio
When I try to download PyAudio I just got this error message. This is so painful. Pls pleh
This might help, since it is the same problem you are having:
pyAudio failed to install : Windows 10
Basically you are missing some components you need before download pyaudio, and those are included by pipwin before installing so you don't have to do it yourself.
when installing pyaudio, pip cannot find portaudio.h in /usr/local/include
Since pyAudio
has portAudio
as a dependency, you first have to install portaudio.
brew install portaudio
Then try: pip install pyAudio
. If the problem persists after installing portAudio
, you can specify the directory path where the compiler will be able to find the source programs (e.g: portaudio.h
). Since the headers should be in the /usr/local/include
directory:
pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio
PyAudio failed to install on Windows 10
Try this (in admin mode command prompt):
pip install pipwin
pipwin install pyaudio
pipwin is like pip, but it installs precompiled Windows binaries provided by Christoph Gohlke. Saves you a lot of googling and manual downloading.
I am trying to install py audio from power shell(vs code) and it is giving me this error
Run the following 2 commands:
pip install pipwin
then
pipwin install pyaudio
How to fix error while trying to install some dependencies using pip
Using pipwin to install pyaudio will solve this
pip install pipwin
then
pipwin install pyaudio
Related Topics
What Does a B Prefix Before a Python String Mean
Confused About Backslashes in Regular Expressions
Append Multiple Values for One Key in a Dictionary
Secondary Axis with Twinx(): How to Add to Legend
Getting Distance Between Two Points Based on Latitude/Longitude
Can You Add New Statements to Python's Syntax
How to Create a Custom String Representation for a Class Object
How Slow Is Python's String Concatenation VS. Str.Join
How to Get Text with Selenium Webdriver in Python
Pygame.Event.Get() Not Returning Any Events When Inside a Thread
How to Check If the String Is Empty
Why Does List.Append() Return None