6

I was following the instructions here and I'm having trouble getting the installation to work. Basically, the first part works fine. I downloaded portaudio, followed the instructions, and it all seemed to work.

However, when I triedpython3 setup.py install, I got an error. The error came from the /src/_portaudiomodule.c file, and it said that "The file Python.h could not be found". I don't really understand what's going on because there was no Python.h file when I extracted the PyAudio archive. I don't know where the Python.h file was supposed to come from.

I'm kind of a noob to unix systems so I could have easily made a mistake somewhere. I've been trying to solve this for hours and I've had no luck so far. Thanks in advance for your help!

user3047641
  • 149
  • 1
  • 2
  • 12
  • Maybe `apt-get install python-dev`. – gavv Oct 01 '15 at 12:59
  • Possible duplicate of [Python.h missing from Ubuntu 12.04](http://stackoverflow.com/questions/15631135/python-h-missing-from-ubuntu-12-04) – gavv Oct 01 '15 at 13:00

6 Answers6

5

To install the latest version of pyaudio using conda:

source activate -your environment name-

pip install pyaudio

You may run into the following error when installing from pip:

src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
 #include "portaudio.h" 
 compilation terminated.
 error: command 'gcc' failed with exit status 1

That is because you don't have the PortAudio development package installed. Install it with:

sudo apt-get install portaudio19-dev
Tomas Ruiz
  • 139
  • 4
  • 15
  • Thanks a lot for the portaudio19-dev installation tip, I was stuck at the portaudio.h error! – xyz Jul 18 '18 at 08:21
4

You don't need to compile pyaudio. To install PyAudio, run:

$ sudo add-apt-repository universe
$ sudo apt-get install python-pyaudio python3-pyaudio

The first command enables Universe Ubuntu repository.

If you want to compile it e.g., to use the latest version from git; install build dependencies:

$ sudo apt-get build-dep python-pyaudio python3-pyaudio

After that, you could install it from sources using pip:

$ python3 -mpip install pyaudio

Or to install the current version from git:

$ pip install -e git+http://people.csail.mit.edu/hubert/git/pyaudio.git#egg=pyaudio

Run pip commands inside a virtualenv or add --user command-line option, to avoid modifying the global python3 installation (leave it to the package manager).

I've tested it on Ubuntu. Let me know if it fails on Mint.

Community
  • 1
  • 1
jfs
  • 399,953
  • 195
  • 994
  • 1,670
  • I wasn't able to get those commands working on ubuntu 16.04 LTS, the wheel was failing to build. – wordsforthewise Jul 07 '16 at 19:38
  • @wordsforthewise: I've just tested it: all commands work. Did you run the `build-dep` command before trying to compile pyaudio? – jfs Jul 07 '16 at 19:54
  • That was giving me an error, add urls to sources.list file, so I added the urls and now the build-dep worked. I already have it installed now though, so I dunno but it would probably work. – wordsforthewise Jul 07 '16 at 20:09
  • @wordsforthewise I've added the explicit command to enable the Universe Ubuntu repository that contains python{,3}-pyaudio Ubuntu packages if you need it (no need to edit `sources.list` manually). – jfs Jul 07 '16 at 21:35
  • In case anyone came here trying to install this on OSX, I had to first run `brew install portaudio` then I ran `pip3 install pyaudio` with no problem. – james-see Jul 05 '18 at 14:50
1

I have found the work arround for mac.

please refer the below steps to install pyaudio on python 3.5

Follow these steps :

  • export HOMEBREW_NO_ENV_FILTERING=1
  • xcode-select --install
  • brew update
  • brew upgrade
  • brew install portaudio
  • pip install pyaudio
Vaibhav K
  • 2,762
  • 3
  • 21
  • 22
0

I was able to get it install with anaconda, using this package.

Follow install instructions for linux here, then do:

conda install -c bokeh pyaudio=0.2.7
wordsforthewise
  • 13,746
  • 5
  • 87
  • 117
0

try to install using the the below command

pip install pyaudio

after that install the required Microsoft Visual C++ 14.0 refer the below image for the same.

enter image description here

and restart the system and run the same command again

pip install pyaudio
Bhaskara Arani
  • 1,556
  • 1
  • 26
  • 44
0

Python.h is nothing but a header file. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications. To install this package, enter:

sudo apt-get install python3-dev
Pratik Parmar
  • 321
  • 3
  • 12