Preferences for playing Wave in Python PyAudio and PortAudio

Abstract

I had a chance to write a program to play wav files using Python, so I was addicted to setting the environment, so I will make a note of it.

What I did at the beginning

PyAudio Official showed how to install for Mac OSX.

$ brew install portaudio 
$ pip install pyaudio

When I tried to install pyaudio


esrc/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
    #include "portaudio.h"
             ^
    1 error generated.
    error: command 'cc' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-vceQ5Y/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 /tmp/pip-ugKOpS-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-vceQ5Y/pyaudio/Q5Y/pyaudio/

I got the error. It looks like I couldn't find portaudio.h. ~~ I put it in properly. ~~

Solution

It seemed like I should explicitly specify the files that have dependencies.

$ sudo pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio

Reference -[Qiita] A workaround when installing pyAudio with pip. --Installing portaudio using mac port

-[Qiita] Code block when writing console (shell) command execution in Qiita --Code block notation ...

Recommended Posts

Preferences for playing Wave in Python PyAudio and PortAudio
Install Pyaudio to play wave in python
Problems and countermeasures for Otsu's binarization overflow in Python
Recursively search for files and directories in Python and output
Search for strings in Python
Techniques for sorting in Python
Stack and Queue in Python
Unittest and CI in Python
About "for _ in range ():" in python
List method argument information for classes and modules in Python
Tips for coding short and easy to read in Python
Useful tricks related to list and for statements in Python
Problems and solutions when asked for MySQL db in Python 3
Check for memory leaks in Python
MIDI packages in Python midi and pretty_midi
Difference between list () and [] in Python
Check for external commands in python
View photos in Python and html
Sorting algorithm and implementation in Python
Manipulate files and folders in Python
About dtypes in Python and Cython
Assignments and changes in Python objects
Check and move directories in Python
Ciphertext in Python: IND-CCA2 and RSA-OAEP
Hashing data in R and Python
Function synthesis and application in Python
Create a CGH for branching a laser in Python (laser and SLM required)
Export and output files in Python
Atom preferences for comfortable Python coding
Run unittests in Python (for beginners)
Reverse Hiragana and Katakana in Python2.7
Reading and writing text in Python
[GUI in Python] PyQt5-Menu and Toolbar-
Create and read messagepacks in Python
python> array> Determine the number and initialize> mylist = [idx for idx in range (10)] / mylist = [0 for idx in range (10)] >> mylist = [0] * 10
UnionFind in python (enhanced version: strings and tuples are allowed for elements)
Build a lightweight server in Python and listen for Scratch 2 HTTP extensions
Overlapping regular expressions in Python and Java
Differences in authenticity between Python and JavaScript
Notes using cChardet and python3-chardet in Python 3.3.1.
Modules and packages in Python are "namespaces"
Avoid nested loops in PHP and Python
Differences between Ruby and Python in scope
AM modulation and demodulation in Python Part 2
difference between statements (statements) and expressions (expressions) in Python
Eigenvalues and eigenvectors: Linear algebra in Python <7>
Notes on nfc.ContactlessFrontend () for nfcpy in python
Inject is recommended for DDD in Python
Implementation module "deque" in queue and Python
Line graphs and scale lines in python
Implement FIR filters in Python and C
Check and receive Serial port in Python (Port check)
Search and play YouTube videos in Python
Summary of various for statements in Python
Type annotations for Python2 in stub files!
Difference between @classmethod and @staticmethod in Python
6 Python libraries for faster development and debugging
Playing card class in Python (with comparison)
Difference between append and + = in Python list
Difference between nonlocal and global in Python
Write O_SYNC file in C and Python