在开始提问之前,我尝试通过这篇文章解决问题,但没有成功:(Link https://stackoverflow.com/questions/33513522/when-installing-pyaudio-pip-cannot-find-portaudio-h-in-usr-local-include)
我使用的是mac(M1 Air)。
我尝试安装 pyaudio,所以我跑了pip install pyaudio
。
然后,我收到以下关于找不到 portaudio.h 的错误:
pip install pyaudio
Collecting pyaudio
Using cached PyAudio-0.2.12.tar.gz (42 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: pyaudio
Building wheel for pyaudio (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /Users/sunwoojeong/anaconda3/bin/python /Users/sunwoojeong/anaconda3/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/jm/hwnp4x291qd9n0vw1p4kzw_m0000gn/T/tmpzv_dfxv_
cwd: /private/var/folders/jm/hwnp4x291qd9n0vw1p4kzw_m0000gn/T/pip-install-y3rg1882/pyaudio_1d880ef087ea42298d89af097d6745ed
Complete output (16 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-cpython-38
copying src/pyaudio.py -> build/lib.macosx-10.9-x86_64-cpython-38
running build_ext
building '_portaudio' extension
creating build/temp.macosx-10.9-x86_64-cpython-38
creating build/temp.macosx-10.9-x86_64-cpython-38/src
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/sunwoojeong/anaconda3/include -arch x86_64 -I/Users/sunwoojeong/anaconda3/include -arch x86_64 -DMACOSX=1 -I/usr/local/include -I/usr/include -I/Users/sunwoojeong/anaconda3/include/python3.8 -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-cpython-38/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/gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for pyaudio
Failed to build pyaudio
ERROR: Could not build wheels for pyaudio which use PEP 517 and cannot be installed directly
因此,经过一些研究,我尝试首先安装并链接 portaudio,如下所示:
brew install portaudio
brew link portaudio
pip install pyaudio
Since brew link portaudio
回报Warning: Already linked: /opt/homebrew/Cellar/portaudio/19.7.0
,我预计 portaudio 已成功安装,并且 pyaudio 的 portaudio.h 文件应该没有问题。但是,即使在安装后,并且显式设置 portaudio 文件夹的路径后,pip install 命令仍然返回此错误。
这是我尝试过的 pip 命令(它们都返回相同的错误):
pip install pyaudio
pip install --global-option='build_ext' --global-option="-I$(brew --prefix)/include" --global-option="-L$(brew --prefix)/lib" pyaudio
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
在使用一些 c-lang 文件安装 python 模块时,是否有人遇到过类似的问题并解决了它?
我认为修复很快就会到来。同时,您应该能够通过执行以下操作来解决该问题:
export CFLAGS="-I/opt/homebrew/include"
export LDFLAGS="-L/opt/homebrew/lib”
pip install pyaudio
祝你好运!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)