Python PyAudio安装问题(使用PortAudio)

Python PyAudio安装问题(使用PortAudio)

问题描述:

我正在尝试编写一个程序来记录计算机麦克风中的信息并将其保存到文件中. PyAudio似乎是执行此操作的较好软件包之一,并且它们甚至都具有Windows 7(Python 2.7)的二进制文件.我下载了可执行文件并运行它来设置PyAudio,但是当我尝试将PyAudio导入python脚本时,出现错误:

I'm trying to write a program to record information from my computers microphone an save it to a file. PyAudio seems like one of the better packages for doing this, and they even have a binary for Windows 7 (Python 2.7). I downloaded the executable file and ran it to set up PyAudio, but when I try to import PyAudio into a python script now I get an error:

Please build and install the PortAudio Python bindings first.

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pyaudio
  File "C:\Python27\lib\site-packages\pyaudio.py", line 103, in <module>
    sys.exit(-1)
SystemExit: -1

如果我查看pyaudio.py,它失败的代码是:

If I look at pyaudio.py, the code that it's failing on is:

# attempt to import PortAudio
try:
    import _portaudio as pa
except ImportError:
    print "Please build and install the PortAudio Python " +\
          "bindings first."
    sys.exit(-1)

另外,如果需要的话,如果我转到Python27\Lib\site-packages(在pyaudio.py所在的位置),有一个名为portaudio_x64.dll的文件.

Also, in case it's relevant, if I go to Python27\Lib\site-packages (where pyaudio.py is) there is a file called portaudio_x64.dll.

他们的站点上的文档似乎仅包含有关要通过源代码进行安装来安装PyAudio的说明.另外,它说二进制文件中包含PortAudio v19,因此我认为它在运行安装程序可执行文件后才可以工作.

The documentation on their site only seems to have instructions for if you want to install PyAudio by building from source code. Additionally, it says that PortAudio v19 is included in the binary, so I assumed it would just work after running the setup executable.

我不知道出了什么问题,我真的需要尽快运行.对出什么问题有任何想法吗?或者,如果有人对适用于Windows 7(64位)和Python 2.7(理想的发行版)以及跨平台的类似软件包有更好的建议,我想听听他们.

I have no idea what's going wrong and I really need this running soon. Any ideas on what's going wrong? Or if anyone has recommendations for similar packages that work better specifically with Windows 7 (64-bit) and Python 2.7 (Enthought distribution), as well as cross-platform, I'd love to hear them.

从注释中复制答案,以便从未答复"过滤器中删除此问题:

Copying the answer from the comments in order to remove this question from the "Unanswered" filter:

尝试使用 http://www.lfd.uci.edu的二进制文件/〜gohlke/pythonlibs/#pyaudio

〜每个 cgohlke