F. Geißler
F. Geißler

Reputation: 258

Trouble installing 'pyaudio' in PyCharm on OS X

I recently tried to install the 'pyaudio' module in my PyCharm IDE. But the installation via the project interpreter results in the following error:

src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found

Screenshot Does anyone know how to fix this problem? I also tried to install different versions, but every time it failed.

Upvotes: 0

Views: 12476

Answers (4)

Zakir saifi
Zakir saifi

Reputation: 436

I somehow resolved the problem by installing packages using pip and importing them into the Pycharm IDE.

I did the following things:-

brew install portaudio
pip3 install pyaudio

It installed a lower version of pyaudio so I upgraded to 0.2.11 by doing these commands:

pip3 install --upgrade pyaudio==0.2.11

Then the neccessary packages will be installed and you can import them on pycharm. For me, they get imported by themselves as I have set the path. Follow this link for help in importing modules in Pycharm: How do I use installed packages in PyCharm?

This is my location for the python module /usr/local/lib/python3.6/site-packages

My Pycharm IDE Snapshot

Upvotes: 3

Ruchika
Ruchika

Reputation: 1

I was getting the exact error, so I changed my python version to 3.6 for the particular environment I am working on.

Try this command at your command prompt. Don’t use SpeechRecognition as that is my environment name. You should choose your own environment name.

Example:

conda create --name SpeechRecognition python=3.6

Then, For activating the new environment, enter:

conda activate SpeechRecognition         

Upvotes: 0

Zafer Atakan
Zafer Atakan

Reputation: 21

I had the same exact error, and I figured out that I was running python 3.6 on pycharm and pip was using 3.7 I typed pip3.6 install pyaudio and problem solved

Actually because I'm totally new to CS, this kind of problem happened more than several times. Always remember to check the versions.

Upvotes: 1

F. Geißler
F. Geißler

Reputation: 258

The way I fixed it, was installing a fresh copy of Python2.7 under

/usr/local/bin/python2.7

And selected that as my Project Interpreter under the PyCharm preferences. Using the internal package manager of PyCharm still throws me error messages, but I'm capable of using the pip package manager through the OSX terminal with no problems so far.

e.g.

pip2.7 install opencv

Upvotes: 0

Related Questions