安装报错
在macOS 10.14,尝试安装pip install pyaduio报错:
Collecting pyaudio
Downloading PyAudio-0.2.11.tar.gz (37 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Using legacy 'setup.py install' for pyaudio, since package 'wheel' is not installed.
Installing collected packages: pyaudio
Running setup.py install for pyaudio: started
Running setup.py install for pyaudio: finished with status 'error'
error: subprocess-exited-with-error
× Running setup.py install for pyaudio did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
running install
/Users/gdlocal/Documents/Lani_work/T03/t03env2/lib/python3.8/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-38
copying src/pyaudio.py -> build/lib.macosx-10.9-x86_64-cpython-38
warning: build_py: byte-compiling is disabled, skipping.
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 -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DMACOSX=1 -I/Users/gdlocal/Documents/Lani_work/T03/t03env2/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-cpython-38/src/_portaudiomodule.o
src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^~~~~~~~~~~~~
1 error generated.
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.
解决方案:
原因是缺少需要调用的系统portaudio库,需要先安装此库 。而安装portaudio,需要通过howebrew工具,来安装。系统上没有brew,百度了很多安装都失败了。
使用以下指令安装brew
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"
安装成功之后,安装portaudio
brew install portaudio
然后是安装pyaudio:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple PyAudio
(t0env2) xxx$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple PyAudio
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting PyAudio
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz (37 kB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for PyAudio, since package 'wheel' is not installed.
Installing collected packages: PyAudio
Running setup.py install for PyAudio ... done
Successfully installed PyAudio-0.2.11
(t0env2) CNQDSX-160136:T03 xxx$
完美解决。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/101599.html