KevinM1990112qwq
KevinM1990112qwq

Reputation: 735

How to fix installation issues for PyAudio, PortAudio: "fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory"

I am having issues installing PyAudio and portaudio.

When I do python -m pip install pyaudio I get this error:

    src/_portaudiomodule.c(29): fatal error C1083: Cannot open include file: 'portaudio.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
Command ""C:\Users\This PC\AppData\Local\Programs\Python\Python37-32\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\THISPC~1\\AppData\\Local\\Temp\\pip-install-3ock7jqh\\pyaudio\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\THISPC~1\AppData\Local\Temp\pip-record-14pe9p6y\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\THISPC~1\AppData\Local\Temp\pip-install-3ock7jqh\pyaudio\

So after looking that error up, I read I need to install portaudio. So I did python -m pip install portaudio and got this error:

Collecting portaudio
Could not find a version that satisfies the requirement portaudio (from versions: )
No matching distribution found for portaudio

I have no idea where to go from here now.

Upvotes: 35

Views: 98516

Answers (11)

Vladislavs Dovgalecs
Vladislavs Dovgalecs

Reputation: 1631

For those who have upgraded pip to version 23.1 above, the option --install-option has been removed. One should use the --config-settings option instead. The command now looks like this on Mac:

$ pip install pyaudio --config-settings="--global-option=build_ext" --config-settings="--global-option=-I/opt/local/include" --config-settings="--global-option=-L/opt/local/lib"

Adjust the -I (include path) and -L (library path) for your system. On Linux it is often prefixed /usr/local.

Upvotes: 0

Hamza
Hamza

Reputation: 133

Use the Following Commands

pip install pipwin
pipwin refresh
pipwin install pyaudio

Upvotes: 0

Chuk Ultima
Chuk Ultima

Reputation: 1037

On Ubuntu distributions you can first run

sudo apt install portaudio19-dev

and then reinstall pyaudio with pip again.

Upvotes: 6

Nord
Nord

Reputation: 31

If you get an error when trying to use pipwin to install this, you have to run it through python as windows doesn't recognize pipwin(at least for me)

pip install pipwin
python -m pipwin install pyaudio

Upvotes: 3

Josué Cano
Josué Cano

Reputation: 141

I installed pyaudio on python 3.6.x without problem, but is not working on later versions.

py -m pip install pyaudio

works perfect on 3.6.x or earlier.

Upvotes: 2

cowlinator
cowlinator

Reputation: 8813

The official PyAudio 0.2.11 does not support Python 3.7+, and trying to install results in the error C1083: Cannot open include file: 'portaudio.h'.

However, there are unofficial wheels for PyAudio that support 3.7+.

If you are using the official version, you must use Python 3.6 with PyAudio 0.2.11.

See http://people.csail.mit.edu/hubert/pyaudio/

Upvotes: 13

hassanzadeh.sd
hassanzadeh.sd

Reputation: 3471

Try This, CMD as Administrator and run the following:

pip install pipwin
pipwin install pyaudio

Upvotes: 76

Mani Agarwal
Mani Agarwal

Reputation: 19

If you are using anaconda then this problem is because your versions are not upgraded.To upgrade all the packages simply run the following command in the terminal.

conda update --all

Upvotes: 0

Sarthak Chauhan
Sarthak Chauhan

Reputation: 1

You can install Portaudio with

pip install port audio

you may also need to

pip install ConfigParser

Let me know if it's work.

Upvotes: -4

AYIBO ROBERTS
AYIBO ROBERTS

Reputation: 55

You can install Anaconda install pyaudio using it. You must add Anaconda to path. After installing Anaconda and adding to path then in your command prompt[cmd] type conda install pyaudio. And whala

Upvotes: 1

abarnert
abarnert

Reputation: 365807

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.

Upvotes: 19

Related Questions