Firstly, I tried
pip install pyaudio
But that didn't work... I found that I need PortAudio, so installed it with brew:
brew install portaudio
That worked and then I restarted my Mac.
But pip install pyaudio still doesn't work and I get the below error message:
ERROR: Command errored out with exit status 1:
command: /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -u -c
'import sys, setuptools, tokenize; sys.argv[0] =
'"'"'/private/var/folders/12/44t6pktj77xbqmyp7x368tdr0000gn/T/pip-install-gvxfbjmp/pyaudio/setup.py'"'"';
file='"'"'/private/var/folders/12/44t6pktj77xbqmyp7x368tdr0000gn/T/pip-install-gvxfbjmp/pyaudio/setup.py'"'"';f=getattr(tokenize,
'"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"',
'"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))'
bdist_wheel -d
/private/var/folders/12/44t6pktj77xbqmyp7x368tdr0000gn/T/pip-wheel-gvmpobvy
cwd: /private/var/folders/12/44t6pktj77xbqmyp7x368tdr0000gn/T/pip-install-gvxfbjmp/pyaudio/
Complete output (16 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.7
copying src/pyaudio.py -> build/lib.macosx-10.14-x86_64-3.7
running build_ext
building '_portaudio' extension
creating build/temp.macosx-10.14-x86_64-3.7
creating build/temp.macosx-10.14-x86_64-3.7/src
xcrun -sdk macosx clang -arch x86_64 -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders
-iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/Headers
-DMACOSX=1 -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/include/python3.7m
-c src/_portaudiomodule.c -o build/temp.macosx-10.14-x86_64-3.7/src/_portaudiomodule.o
src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command 'xcrun' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pyaudio
I also tried pip3 install pyaudio without any luck.
BTW I am just doing this because I want to use the Python Speech Recognition API and I think pyaudio is necessary... is it?
Very likely you need to specify the directory path where the compiler can find the source programs like portaudio.h.
Under assumption that the headers are in /usr/local/include directory, try to run the below command in the Terminal:
pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio
your problem is that with the Xcode command-line. Reinstall using this
xcode-select --install
after xcode is fixed the command('xcrun') should be able to run so just reuse
pip3 install pyaudio
you may need to upgrade pip
python3 -m pip install --upgrade pip
-- Successfully installed pip-21.2.4
and/or invoke pip3
pip3 install ...
Related
Why do I always get this error when I try to install accumulation-tree? I need this for optbinning. A similar package would also be a solution.
ERROR: Command errored out with exit status 1:
command: /Users/elisaderoo/opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/yc/59hh1mg16c90lpnfsfvwcnf80000gn/T/pip-install-29thp5kc/accumulation-tree/setup.py'"'"'; __file__='"'"'/private/var/folders/yc/59hh1mg16c90lpnfsfvwcnf80000gn/T/pip-install-29thp5kc/accumulation-tree/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/yc/59hh1mg16c90lpnfsfvwcnf80000gn/T/pip-wheel-4djg7a0d
cwd: /private/var/folders/yc/59hh1mg16c90lpnfsfvwcnf80000gn/T/pip-install-29thp5kc/accumulation-tree/
Complete output (19 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.8
creating build/lib.macosx-10.9-x86_64-3.8/accumulation_tree
copying accumulation_tree/treeslice.py -> build/lib.macosx-10.9-x86_64-3.8/accumulation_tree
copying accumulation_tree/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/accumulation_tree
copying accumulation_tree/abctree.py -> build/lib.macosx-10.9-x86_64-3.8/accumulation_tree
running build_ext
cythoning accumulation_tree/accumulation_tree.pyx to accumulation_tree/accumulation_tree.c
/Users/elisaderoo/opt/anaconda3/lib/python3.8/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /private/var/folders/yc/59hh1mg16c90lpnfsfvwcnf80000gn/T/pip-install-29thp5kc/accumulation-tree/accumulation_tree/accumulation_tree.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
building 'accumulation_tree.accumulation_tree' extension
creating build/temp.macosx-10.9-x86_64-3.8
creating build/temp.macosx-10.9-x86_64-3.8/accumulation_tree
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/elisaderoo/opt/anaconda3/include -arch x86_64 -I/Users/elisaderoo/opt/anaconda3/include -arch x86_64 -I/Users/elisaderoo/opt/anaconda3/include/python3.8 -c accumulation_tree/accumulation_tree.c -o build/temp.macosx-10.9-x86_64- 3.8/accumulation_tree/accumulation_tree.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for accumulation-tree
This error might be due to not having Cython installed. Alternatively, you can clone the repository from GitHub, remove the dependency tdigest from the list of install_requires in setup.py, and install from the source using python setup.py install.
Try running (in a terminal window)
xcode-select –install
(and clicking through dialog)
If that doesn't work try:
sudo xcode-select --reset
Several links show this problem in other contexts (e.g.)
https://developer.apple.com/forums/thread/673827
Fatal Error (invalid active developer path ) After Upgrading R / R Studio
you may not have installed gfortran
first try to install it
sudo apt install gfortran
I got the following error while trying to install pyaudio using pip3 in ubuntu 16.04:
Collecting pyaudio
Downloading PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/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-v55chjee-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
copying src/pyaudio.py -> build/lib.linux-x86_64-3.5
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.5/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/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-v55chjee-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-mxgvewdb/pyaudio/
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
For Windows, here's what I've been going through...
There're several ways to install PortAudio
vcpkg, https://vcpkg.info/port/portaudio
winget, https://winget.run/pkg/intxcc/pyaudio
Or, manually build from source and install manually
download source, http://files.portaudio.com/download.html
build with cmake, with the matching compiler(msvc/mingw) and arch(x64/x86) to your Python
put "portaudio.h" into python-include directory, e.g. c:\Python38-32\include\
put "portaudio.lib into python-lib directory, e.g. c:\Python38-32\libs
Arrh!
the "min()" macro in pyaudio's soucefile _portaudiomodule.c is troublesome, comment it out manually
pip install pyaudio --no-clean
find _portaudiomodule.c in the temp directory and manually comment-out the "min()" macro e.g. c:\Temp\pip-install-yysb8bme\pyaudio_c92585\src\_portaudiomodule.c
pip install from that directorye.g. pip install c:\Temp\pip-install-yysb8bme\pyaudio_c92585\
Or,3rd party wheels
this answer said:
pip install pipwinpipwin install pyaudio
For MacOS (Intel/Apple Silicon):
Step 1:
brew install portaudio
Step 2:
brew --prefix portaudio
The output provided from the above command, will be required in Step 3, which will look something similar to /opt/homebrew/opt/portaudio
Step 3:
Create .pydistutils.cfg in your home directory
sudo nano ~/.pydistutils.cfg
then paste the following in the file, save and exit
[build_ext]
include_dirs=<PATH FROM STEP 2>/include/
library_dirs=<PATH FROM STEP 2>/lib/
Step 4:
pip3 install pyaudio
For Centos7/RHEL:
yum install portaudio-devel alsa-lib-devel portaudio
pip install pyaudio --user
I am running mysql#8.x version on my MacOS, I have installed mysql and mysql-connector-o with brew. Currently brew link with mysql.
Running Django project on my python3 virtual env I am receiving following error -
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'.
Did you install mysqlclient or MySQL-python?
and on installing the mysqlclient using pip, I am reciving following error
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 -I/usr/local/Cellar/mysql/8.0.12/include/mysql -I/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c _mysql.c -o build/temp.macosx-10.13-x86_64-3.6/_mysql.o
clang -bundle -undefined dynamic_lookup -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk build/temp.macosx-10.13-x86_64-3.6/_mysql.o -L/usr/local/Cellar/mysql/8.0.12/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.13-x86_64-3.6/_mysql.cpython-36m-darwin.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
----------------------------------------
Command "/Volumes/Samsung_T5/Work/python/repos/venv3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-install-kf2fkhtc/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/tmp/pip-record-qwpjjw3e/install-record.txt --single-version-externally-managed --compile --install-headers /Volumes/Samsung_T5/Work/python/repos/venv3/bin/../include/site/python3.6/mysqlclient" failed with error code 1 in /private/tmp/pip-install-kf2fkhtc/mysqlclient/
As jordanm pointed it out, the issue was exactly with the missing openssl libraries, for which I followed these steps to fix my issue -
Installing openssl
brew install openssl
Now
pip install mysqlclient should work.
If it doesn't and still shows the same error library not found for -lssl, you could also try to link against brew's openssl:
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install mysqlclient
if this still does not work, you might need to use the --no-cache option of pip, e.g.
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip --no-cache install mysqlclient
After installing openssl via Homebrew I placed
export PATH="/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
in my .bash_profile and ran
source .bash_profile
and then
pip install mysqlclient
This question already has answers here:
Pyaudio installation error - 'command 'gcc' failed with exit status 1'
(10 answers)
Closed 4 years ago.
Pyaudio Installation failure on Ubuntu
I have ubuntu 18LTS
python 2 and python 3
pip 10
I installed libportaudio2 and libasound-dev from suggestions I found on google. Is it because I need to install other libraries as well?
Here is the error I got
I tried the sudo -H flag but no difference.
sudo python -m pip install pyaudio
The directory '/home/ec2/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ec2/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pyaudio
Downloading https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-wGfA8D/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-record-IYb2Y1/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying src/pyaudio.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-nbjU53/python2.7-2.7.15~rc1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o
src/_portaudiomodule.c:29:10: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
^~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-wGfA8D/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-record-IYb2Y1/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-wGfA8D/pyaudio/
fatal error: portaudio.h: No such file or directory
you are missing some build dependencies, so it fails compilation. specifically, the error shows it can't find portaudio.h, which comes with the portaudio19-dev package.
so install the required headers with:
sudo apt-get install portaudio19-dev
then try your pip install.
You can try
sudo apt-get install python-pyaudio
Try this before installing the package:
sudo apt-get install portaudio19-dev
If the above suggestion doesn't work:
sudo apt-get install libjack-jackd2-dev portaudio19-dev
and pip install pyaudio should work.
I'm trying to install pyaudio with pip:
pip install pyaudio
In a virtualenv but I'm getting an error:
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Entire output:
Collecting pyaudio
Using cached PyAudio-0.2.9.tar.gz
Building wheels for collected packages: pyaudio
Running setup.py bdist_wheel for pyaudio ... error
Complete output from command /home/mertyildiran/Downloads/VirtualEnvironment/vir1/Cerebrum/ENV/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-GCltlv/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpyR6J73pip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying src/pyaudio.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for pyaudio
Running setup.py clean for pyaudio
Failed to build pyaudio
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command /home/mertyildiran/Downloads/VirtualEnvironment/vir1/Cerebrum/ENV/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-GCltlv/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-icMIUV-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/mertyildiran/Downloads/VirtualEnvironment/vir1/Cerebrum/ENV/include/site/python2.7/pyaudio:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying src/pyaudio.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/mertyildiran/Downloads/VirtualEnvironment/vir1/Cerebrum/ENV/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-GCltlv/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-icMIUV-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/mertyildiran/Downloads/VirtualEnvironment/vir1/Cerebrum/ENV/include/site/python2.7/pyaudio" failed with error code 1 in /tmp/pip-build-GCltlv/pyaudio
What am I doing wrong? I'm new in virtualenvs.
*I'm able to install other packages. I'm facing with an error only for pyaudio package.
By the way I'm in the environment:
(ENV) mertyildiran#Corsair:~/Downloads/VirtualEnvironment/vir1/MyProject$
This worked for me, I had the same problem:
if you want to install PyAudio inside a virtualenv, install the PortAudio development headers from APT, then PyAudio:
sudo apt-get install portaudio19-dev
pip install --allow-unverified=pyaudio pyaudio
https://pyspotify.mopidy.com/en/latest/api/sink/
Some packages require the support of non-Python software, such as shared libraries. These cannot be installed via pip (they're not Python packages!). You generally install these on the host using your host's package manager (apt-get or yum or dnf, etc...), or you use something like Docker to encapsulate both the dependencies and your application.
In your case, pyaudio requires a number of libraries, including at least portaudio. You will need to install the appropriate development packages on your system, as suggested in the comments on your question.
Following steps worked for me :) Please go through and try
1 sudo apt-get install libasound-dev
2 sudo apt-get install portaudio19-dev
3 pip install pyaudio --user
OR (--user dont work then try python3-pyaudio)
sudo apt-get install python3-pyaudio
In new Python 3.0 pyaudio can install in windows use following command:
pip3 install pyaudio.
If you want to install pyaudio in virtual environment in windows
first you need to download PyAudio-0.2.11-cp37-cp37m-win_amd64.whl this file in [https://www.lfd.uci.edu/~gohlke/pythonlibs/] here and then open command prompt and go to the path where your downloaded file located and type pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl