如何使用Python 3在Mac上安装pyaudio? [英] How to install pyaudio on mac using Python 3?

查看:62
本文介绍了如何使用Python 3在Mac上安装pyaudio?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次尝试:

pip install pyaudio

但是我被告知

-bash: pip: command not found

然后我尝试:

pip3 install pyaudio

然后我得到了:

src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found

#include "portaudio.h"

         ^

1 error generated.

error: command '/usr/bin/clang' failed with exit status 1

----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 -c "import setuptools, tokenize;__file__='/private/var/folders/77/gz1txkwj2z925vk6jrkx3wp80000gn/T/pip-build-43z_qk7o/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/77/gz1txkwj2z925vk6jrkx3wp80000gn/T/pip-tkf78ih4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/77/gz1txkwj2z925vk6jrkx3wp80000gn/T/pip-build-43z_qk7o/pyaudio

但是我已经安装了portaudio

but I had installed portaudio

brew install portaudio

警告:已安装portaudio-19.20140130

Warning: portaudio-19.20140130 already installed

那我该怎么办?

推荐答案

我假设您使用的是Mac.这是一个简单的问题.

I'm assuming you are on a Mac. This is a simple issue to fix.

首先安装Xcode.然后重新启动计算机.然后依次运行命令,

First install Xcode. Then restart your computer. Afterwards run the commands in sequence,

xcode-select --install
brew remove portaudio
brew install portaudio
pip3 install pyaudio

为澄清起见,Xcode是通过App Store安装的.Xcode命令行工具对于某些安装是必需的,对于其他安装则不是.为了安全起见,我将其包括在此处.您可能还不需要通过Homebrew卸载并重新安装公式,我这样做是为了确保绝对不会出现问题.

So to clarify, Xcode is installed through the App Store. Xcode command line tools are required for some installations, for others they are not. I'm including it here just to be on the safe side. You also probably do not need to uninstall and reinstall the formula via Homebrew, I did that to ensure that there would be absolutely no problems.

有人告诉我Homebrew需要Xcode.因此,只需运行

I have been told Homebrew requires Xcode. So just run the

xcode-select --install

命令可以使用Clang.还有您使用的是哪个版本的Mac?

command to be able to use Clang. Also what version of Mac are you on?

这篇关于如何使用Python 3在Mac上安装pyaudio?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆