how to fix "Failed building wheel for pyAudio"? - python

Collecting pyAudio
Using cached PyAudio-0.2.13.tar.gz (46 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyAudio
Building wheel for pyAudio (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pyAudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [15 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-cpython-310
creating build/lib.macosx-10.9-universal2-cpython-310/pyaudio
copying src/pyaudio/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/pyaudio
running build_ext
building 'pyaudio._portaudio' extension
creating build/temp.macosx-10.9-universal2-cpython-310
creating build/temp.macosx-10.9-universal2-cpython-310/src
creating build/temp.macosx-10.9-universal2-cpython-310/src/pyaudio
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -DMACOS=1 -I/usr/local/include -I/usr/include -I/opt/homebrew/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c src/pyaudio/device_api.c -o build/temp.macosx-10.9-universal2-cpython-310/src/pyaudio/device_api.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyAudio
Failed to build pyAudio
ERROR: Could not build wheels for pyAudio, which is required to install pyproject.toml-based projects
getting error when im trying to install pyaudio

Related

Cannot install blockchain_parser getting 'legacy-install-failure'

I am working on a code which will require me to parse the bitcoin data for that i am using blockchain parser package which i found from the github repo below
https://github.com/alecalve/python-bitcoin-blockchain-parser
I tried installing pip3 install blockchain_parse and i also tried pip3 install plyvel and i am only getting the following error:
Defaulting to user installation because normal site-packages is not writeable
Collecting blockchain_parser
Using cached blockchain_parser-0.1.5-py3-none-any.whl (29 kB)
Requirement already satisfied: python-bitcoinlib==0.11.0 in /Users/krina/Library/Python/3.9/lib/python/site-packages (from blockchain_parser) (0.11.0)
Collecting plyvel==1.2.0
Using cached plyvel-1.2.0.tar.gz (145 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: plyvel
Building wheel for plyvel (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-cpython-39
creating build/lib.macosx-10.9-universal2-cpython-39/plyvel
copying plyvel/_version.py -> build/lib.macosx-10.9-universal2-cpython-39/plyvel
copying plyvel/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/plyvel
running build_ext
building 'plyvel._plyvel' extension
creating build/temp.macosx-10.9-universal2-cpython-39
creating build/temp.macosx-10.9-universal2-cpython-39/plyvel
clang -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.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -c plyvel/_plyvel.cpp -o build/temp.macosx-10.9-universal2-cpython-39/plyvel/_plyvel.o -Wall -g -x c++ -std=c++11 -stdlib=libc++
plyvel/_plyvel.cpp:4:10: fatal error: 'Python.h' file not found
#include "Python.h"
^~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for plyvel
Running setup.py clean for plyvel
Failed to build plyvel
Installing collected packages: plyvel, blockchain_parser
Running setup.py install for plyvel ... error
error: subprocess-exited-with-error
× Running setup.py install for plyvel did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
running install
/Users/krina/Library/Python/3.9/lib/python/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-cpython-39
creating build/lib.macosx-10.9-universal2-cpython-39/plyvel
copying plyvel/_version.py -> build/lib.macosx-10.9-universal2-cpython-39/plyvel
copying plyvel/__init__.py -> build/lib.macosx-10.9-universal2-cpython-39/plyvel
running build_ext
building 'plyvel._plyvel' extension
creating build/temp.macosx-10.9-universal2-cpython-39
creating build/temp.macosx-10.9-universal2-cpython-39/plyvel
clang -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.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -c plyvel/_plyvel.cpp -o build/temp.macosx-10.9-universal2-cpython-39/plyvel/_plyvel.o -Wall -g -x c++ -std=c++11 -stdlib=libc++
plyvel/_plyvel.cpp:4:10: fatal error: 'Python.h' file not found
#include "Python.h"
^~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> plyvel
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
I tried to create a virtual environment as well which is also not working.
Can someone make me understand what is wrong here and how can i solve it and if there are any other blockchain parsers that i can use. Thank you!
blockchain-parser only supports plyvel 1.2.0
plyvel 1.2.0 only support Python 3.8
Please check your python version is correct.
https://plyvel.readthedocs.io/en/latest/news.html
Try this:
brew install leveldb
pip install plyvel==1.2.0
pip install blockchain-parser

portaudio.h not found when installing pyaudio in Mac

I created a virtual environment like this
mkdir ai
cd ai
conda create --prefix ./env python=3.8
conda activate ./env
and installed libraries
brew install portaudio
pip install pyaudio
but an error was thrown
Collecting pyaudio
Using cached PyAudio-0.2.12.tar.gz (42 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pyaudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-11.0-arm64-cpython-310
copying src/pyaudio.py -> build/lib.macosx-11.0-arm64-cpython-310
running build_ext
building '_portaudio' extension
creating build/temp.macosx-11.0-arm64-cpython-310
creating build/temp.macosx-11.0-arm64-cpython-310/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/premkumarsinha/miniforge3/include -arch arm64 -fPIC -O2 -isystem /Users/premkumarsinha/miniforge3/include -arch arm64 -DMACOSX=1 -I/usr/local/include -I/usr/include -I/Users/premkumarsinha/miniforge3/include/python3.10 -c src/_portaudiomodule.c -o build/temp.macosx-11.0-arm64-cpython-310/src/_portaudiomodule.o
src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
So I ran this
brew find portaudio
and I got the dir for it;
/opt/homebrew/Cellar/portaudio/19.7.0
than I ran this command
pip install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib' pyaudio
But still I am getting the same error what should I do.

I tried everything to install pyaudio on macOS Monterrey

I installed brew
Use brew install portaudio
I link with brew link portaudio
Installed pyaudio with pip install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib' pyaudio
and I tried install with pip install pyaudio and pip3 install pyaudio
But unhappily I always have the same error
Collecting pyaudio
Using cached PyAudio-0.2.12.tar.gz (42 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pyaudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [18 lines of output]
Error in sitecustomize; set PYTHONVERBOSE for traceback:
AssertionError:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-12-arm64-cpython-310
copying src/pyaudio.py -> build/lib.macosx-12-arm64-cpython-310
running build_ext
building '_portaudio' extension
creating build/temp.macosx-12-arm64-cpython-310
creating build/temp.macosx-12-arm64-cpython-310/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -DMACOSX=1 -I/usr/local/include -I/usr/include -I</opt/homebrew/opt/portaudi>include/ -I/opt/homebrew/opt/python#3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c src/_portaudiomodule.c -o build/temp.macosx-12-arm64-cpython-310/src/_portaudiomodule.o
src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects
I have the same issue as well, but following work-around worked for me.
Install portaudio
brew install portaudio
Link
brew link portaudio
Locate the library and includes
sudo find / -name "portaudio.h"
Use it with global options
pip3 install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include/' --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib/' pyaudio
But this fails as you are pointing above. For some reason, it doesn't include the path for libs and include with build_ext option.
Downloading PyAudio-0.2.12.tar.gz (42 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.9/42.9 kB 1.6 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pyaudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-11.0-arm64-cpython-39
copying src/pyaudio.py -> build/lib.macosx-11.0-arm64-cpython-39
running build_ext
building '_portaudio' extension
creating build/temp.macosx-11.0-arm64-cpython-39
creating build/temp.macosx-11.0-arm64-cpython-39/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/koteshk/miniforge3/include -arch arm64 -fPIC -O2 -isystem /Users/koteshk/miniforge3/include -arch arm64 -DMACOSX=1 -I/usr/local/include -I/usr/include -I/Users/koteshk/miniforge3/include/python3.9 -c src/_portaudiomodule.c -o build/temp.macosx-11.0-arm64-cpython-39/src/_portaudiomodule.o
src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
Work around
Manually copy the libs and include files to one of the system paths. Note you may have to create the directory if it's not present.
sudo cp -r /opt/homebrew/Cellar/portaudio/19.7.0/include/* /usr/local/include
sudo cp -r /opt/homebrew/Cellar/portaudio/19.7.0/lib/* /usr/local/lib
Install pyaudio
pip install pyaudio
OK, I solved my own problem. To solved this problem portaudio.h just follow the topics bellow.
Pyaudio for MACOS users --> Project with Speech Recognition
Install homebrew --> https://brew.sh/index_pt-br
brew install portaudio
brew link portaudio
type LDFLAGS="-L$(brew --prefix portaudio)/lib" CFLAGS="-I$(brew --prefix portaudio)/include" pip install pyaudio
brew install flac --> https://formulae.brew.sh/formula/flac
install speech_recognition with pip

Cannot for the life of me get portaudio install on my M1Pro Macbook Pro

sudo -H pip install pyaudio --global-option="build_ext" --global-option="-I/opt/homebrew/include" --global-option="-L/opt/homebrew/lib"
WARNING: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.
Collecting pyaudio
Downloading PyAudio-0.2.12.tar.gz (42 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.9/42.9 kB 872.0 kB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pyaudio (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-12-arm64-cpython-39
copying src/pyaudio.py -> build/lib.macosx-12-arm64-cpython-39
running build_ext
building '_portaudio' extension
creating build/temp.macosx-12-arm64-cpython-39
creating build/temp.macosx-12-arm64-cpython-39/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -DMACOSX=1 -I/usr/local/include -I/usr/include -I/opt/homebrew/Cellar/python#3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/_portaudiomodule.c -o build/temp.macosx-12-arm64-cpython-39/src/_portaudiomodule.o
src/_portaudiomodule.c:31:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio, which is required to install pyproject.toml-based projects
When I run the command, no matter what - pip install pyaudio, or the above command with/without sudo it always gives the same error. I see this is a very common issue. I double checked the path and portaudio in the directory used in the command. I am at a loss and really do not understand why it is not working. I also tried building pyaudio directly from the file itself and it still doesn't work. Does anyone have any suggestions?
SOLVED: I found this: https://qiita.com/yukilab/items/d50a10f1d46c44ae0757
even though it is in another language I was able to get it working. It is similar to what was suggested by #Bob th but slightly different.
In essence I made a file .pydistutils.cfg and added
[build_ext]
include_dirs=/opt/homebrew/include
library_dirs=/opt/homebrew/lib

Cannot install pyAudio [duplicate]

This question already has answers here:
Error on "pip install -U channels" command using for otree (Running setup.py bdist_wheel for twisted ... error)
(1 answer)
Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)
(37 answers)
Closed 9 months ago.
I'm trying to install pyAudio using pip for a Voice Assistant project I'm building. When I try to run the code, it returns this error saying no module named 'pyaudio'. So I assumed I have to install pyaudio again in order to make it work.
But while installing pyaudio, I'm getting this error. I've tried many methods like installing portaudio, clearing cache of pip, updating, uninstalling, re-installing packages, pip and python.
I'm fairy new to python so please don't mind if this is a rookie error.
macOS 12.3.1, Python 3.9.1, env virtual environment
Collecting pyaudio
Using cached PyAudio-0.2.11.tar.gz (37 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [13 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-cpython-39
copying src/pyaudio.py -> build/lib.macosx-10.9-x86_64-cpython-39
running build_ext
building '_portaudio' extension
creating build/temp.macosx-10.9-x86_64-cpython-39
creating build/temp.macosx-10.9-x86_64-cpython-39/src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DMACOSX=1 -I/Users/setukumar/Downloads/Virtual-Personal-Assistant-using-Python-master/env/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-cpython-39/src/_portaudiomodule.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: 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
error: subprocess-exited-with-error
× Running setup.py install for pyaudio did not run successfully.
│ exit code: 1
╰─> [15 lines of output]
running install
/Users/setukumar/Downloads/Virtual-Personal-Assistant-using-Python-master/env/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-cpython-39
copying src/pyaudio.py -> build/lib.macosx-10.9-x86_64-cpython-39
running build_ext
building '_portaudio' extension
creating build/temp.macosx-10.9-x86_64-cpython-39
creating build/temp.macosx-10.9-x86_64-cpython-39/src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DMACOSX=1 -I/Users/setukumar/Downloads/Virtual-Personal-Assistant-using-Python-master/env/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-cpython-39/src/_portaudiomodule.o
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> pyaudio
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Try this one:
sudo apt-get install portaudio19-dev
Then Try again

Categories