在运行Snow Leopard的Mac上构建PortAudio和PyAudio(拱门问题)

时间:2010-05-23 19:51:49

标签: python portaudio pyaudio

我想告诉你我尝试了什么,然后我非常欢迎你能提供关于如何正确设置PortAudio和PyAudio的评论!

我尝试从运行Snow Leopard的Core 2 Duo MacBook Pro安装their website的PortAudio的stable和svn版本。稳定版本的sizeof错误为can be fixed(?),但每日svn版本与./configure && make && make install安装良好(所以这就是我正在使用的)。测试编译正确,我可以得到二进制文件以产生输出/可以读取麦克风输入。

好的,那么PyAudio就有麻烦了。从source安装我收到有关未找到库的错误:

mwoods 13 pyaudio-0.2.3$ python setup.py build
running build
running build_py
running build_ext
building '_portaudio' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -DMACOSX=1 -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _portaudiomodule.c -o build/temp.macosx-10.6-universal-2.6/_portaudiomodule.o -fno-strict-aliasing
_portaudiomodule.c:35:25: error: pa_mac_core.h: No such file or directory
_portaudiomodule.c:679: error: expected specifier-qualifier-list before ‘PaMacCoreStreamInfo’
_portaudiomodule.c: In function ‘_pyAudio_MacOSX_hostApiSpecificStreamInfo_cleanup’:
_portaudiomodule.c:690: error: ‘_pyAudio_Mac_HASSI’ has no member named ‘paMacCoreStreamInfo’
_portaudiomodule.c:691: error: ‘_pyAudio_Mac_HASSI’ has no member named ‘paMacCoreStreamInfo’
_portaudiomodule.c:692: error: ‘_pyAudio_Mac_HASSI’ has no member named ‘paMacCoreStreamInfo’
_portaudiomodule.c:695: error: ‘_pyAudio_Mac_HASSI’ has no member named ‘channelMap’
_portaudiomodule.c:696: error: ‘_pyAudio_Mac_HASSI’ has no member named ‘channelMap’
_portaudiomodule.c:699: error: ‘_pyAudio_Mac_HASSI’ has no member named ‘flags’

... another 100 lines of this ...

_portaudiomodule.c:2471: error: ‘paMacCoreMinimizeCPUButPlayNice’ undeclared (first use in this function)
_portaudiomodule.c:2473: error: ‘paMacCoreMinimizeCPU’ undeclared (first use in this function)
lipo: can't open input file: /var/folders/Qc/Qcl516fqHAWupTUV9BE9rU+++TI/-Tmp-//cc7BqpBc.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1

我可以从their .dmg installer安装PyAudio,但它的目标是python2.5。如果我将/Library/Python/2.5/site-packages/的所有相关内容复制到/Library/Python/2.6/site-packages/(这包括PyAudio-0.2.3-py2.5.egg-info,_portaudio .so,pyaudio.py,pyaudio.pyc和pyaudio.pyo)然后我的python2.6可以识别它。

In [1]: import pyaudio
Please build and install the PortAudio Python bindings first.
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/pyaudio.py", line 103, in <module>
    sys.exit(-1)
SystemExit: -1

Type %exit or %quit to exit IPython (%Exit or %Quit do so unconditionally).

In [2]: 

因此无法导入_portaudio,因此会发生这种情况。如果我尝试直接导入它:

In [2]: import _portaudio
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
ImportError: /Library/Python/2.6/site-packages/_portaudio.so: no appropriate 64-bit architecture (see "man python" for running in 32-bit mode)

好的,所以如果我export VERSIONER_PYTHON_PREFER_32_BIT=yes然后再次运行python(好吧,我想是ipython),我们可以看到它有效但有后果:

In [1]: import pyaudio

In [2]: pyaudio
Out[2]: <module 'pyaudio' from '/Library/Python/2.6/site-packages/pyaudio.pyc'>

In [3]: import pylab
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/__init__.py", line 129, in <module>
    from rcsetup import defaultParams, validate_backend, validate_toolbar
  File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/rcsetup.py", line 19, in <module>
    from matplotlib.colors import is_color_like
  File "/Library/Python/2.6/site-packages/matplotlib-1.0.svn_r8037-py2.6-macosx-10.6-universal.egg/matplotlib/colors.py", line 52, in <module>
    import numpy as np
  File "/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542_20091216-py2.6-macosx-10.6-universal.egg/numpy/__init__.py", line 130, in <module>
    import add_newdocs
  File "/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542_20091216-py2.6-macosx-10.6-universal.egg/numpy/add_newdocs.py", line 9, in <module>
    from lib import add_newdoc
  File "/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542_20091216-py2.6-macosx-10.6-universal.egg/numpy/lib/__init__.py", line 4, in <module>
    from type_check import *
  File "/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542_20091216-py2.6-macosx-10.6-universal.egg/numpy/lib/type_check.py", line 8, in <module>
    import numpy.core.numeric as _nx
  File "/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542_20091216-py2.6-macosx-10.6-universal.egg/numpy/core/__init__.py", line 5, in <module>
    import multiarray
ImportError: dlopen(/Library/Python/2.6/site-packages/numpy-1.4.0.dev7542_20091216-py2.6-macosx-10.6-universal.egg/numpy/core/multiarray.so, 2): no suitable image found.  Did find:
    /Library/Python/2.6/site-packages/numpy-1.4.0.dev7542_20091216-py2.6-macosx-10.6-universal.egg/numpy/core/multiarray.so: mach-o, but wrong architecture

我们可以假设pylab之前正在工作!我花了一段时间才开始这么做,但有人可以帮助这个安装或从成功的Snow Leopard安装中获得建议吗?对于这篇长篇文章感到抱歉,但我只是因为提供部分信息而臭名昭着,我正试图解决这个问题!

2 个答案:

答案 0 :(得分:5)

感谢PyAudio的作者对我的查询的快速反应,我现在有一个安装得很好的副本。对于有类似问题的人,他的指示如下。

  

嗨,迈克尔,

     

试试这个:

     

1)确保你的目录布局是   像:

     

./ foo / pyaudio / portaudio-v19 / ./foo/pyaudio /

     

2)从源代码构建portaudio-v19,   就像你做的那样

     

3)cd ./foo/pyaudio/ 4)python   setup.py build --static-link

     

(参见顶部的评论   setup.py了解更多信息   --static链路)

     

如果一切顺利,请在里面   ./foo/pyaudio/build/lib.macosx-10.6-.../,   你会找到建造的(胖)物体   包括i386,ppc和x86_64   二进制文件。你也可以做一个“python   setup.py安装“如果你愿意。

     

最好,休伯特

答案 1 :(得分:1)

我使用的是Mac 10.5.8 Intel Core 2 duo并遇到了同样的问题。 您需要的目录布局是

./foo/pyaudio/portaudio-v19/
./foo/pyaudio

原因是setup.py具有以下内容: portaudio_path = os.environ.get(“PORTAUDIO_PATH”,“。/ portaudio-v19”)

或者,您应该能够设置PORTAUDIO_PATH env变量并使其工作。