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

发布于 2024-09-02 20:09:57 字数 6142 浏览 10 评论 0原文

我想告诉您我已经尝试过的内容,然后我非常欢迎您提供有关如何正确设置 PortAudio 和 PyAudio 的任何评论!

我尝试从 他们的网站为我的 Core 2 Duo 安装 PortAudio 的稳定版本和 svn 版本运行 Snow Leopard 的 MacBook Pro。稳定版本存在 sizeof 错误,可以已修复(?),但每日 svn 版本可以通过 ./configure && 安装正常。制作&& make install (这就是我正在使用的)。测试已正确编译,我可以让二进制文件产生输出/可以读取麦克风输入。

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

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

我可以安装PyAudio 来自 他们的 .dmg 安装程序,但它针对的是 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)

好的,所以如果我导出 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 安装中提供建议吗?抱歉发了这么长的帖子,但我因只提供部分信息而臭名昭著,我正在努力解决这个问题!

I'd like to tell you what I've tried and then I'd really welcome any comments you can provide on how I can get PortAudio and PyAudio setup correctly!

I've tried installing the stable and svn releases of PortAudio from their website for my Core 2 Duo MacBook Pro running Snow Leopard. The stable release has a sizeof error that can be fixed(?), but the daily svn release installs fine with ./configure && make && make install (so this is what I'm using). The tests are compiled properly and I can get the binaries to produce output/can read microphone input.

Ok, so then PyAudio has troubles. Installing from source I get errors about not finding the libraries:

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

I can install PyAudio from their .dmg installer, but it targets python2.5. If I copy all of the related contents of /Library/Python/2.5/site-packages/ to /Library/Python/2.6/site-packages/ (this includes PyAudio-0.2.3-py2.5.egg-info, _portaudio.so, pyaudio.py, pyaudio.pyc, and pyaudio.pyo) then my python2.6 can recognize it.

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]: 

So this happens because _portaudio can't be imported. If I try to import that directly:

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)

Ok, so if I export VERSIONER_PYTHON_PREFER_32_BIT=yes and then run python again (well, ipython I suppose), we can see it works but with consequences:

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

We can assume pylab was working before! I spent a while getting this far, but can someone help with this install or lend advice from a successful Snow Leopard install? Sorry for the long post, but I'm notorious for only giving partial information and I'm trying to fix that!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长伴 2024-09-09 20:09:57

感谢 PyAudio 的作者对我的询问的快速回复,我现在拥有了一个安装良好的副本。他的指示发布在下面,供有类似问题的任何人使用。

嗨迈克尔,

试试这个:

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

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

2) 从源代码构建 portaudio-v19,
正如你所做的那样

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

(请参阅顶部的评论
setup.py 了解更多信息
--静态链接)

如果一切顺利的话,里面
./foo/pyaudio/build/lib.macosx-10.6-.../,
你会发现构建的(胖)对象
包括 i386、ppc 和 x86_64
二进制文件。你也可以做一个“python
setup.py install”如果你愿意的话。

最好,休伯特

Thanks to PyAudio's author's speedy response to my inquiries, I now have a nicely installed copy. His directions are posted below for anyone who has similar issues.

Hi Michael,

Try this:

1) Make sure your directory layout is
like:

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

2) Build portaudio-v19 from sources,
as you have done

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

(See the comments at the top of
setup.py for more info on
--static-link)

If all goes well, inside
./foo/pyaudio/build/lib.macosx-10.6-.../,
you'll find the built (fat) objects
comprising i386, ppc, and x86_64
binaries. You can also do a "python
setup.py install" if you like.

Best, Hubert

北风几吹夏 2024-09-09 20:09:57

我在 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 环境变量并使其正常工作。

I'm on Mac 10.5.8 Intel Core 2 duo and hitting the same issue.
The directory layout you need is

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

The reason is setup.py has the following:
portaudio_path = os.environ.get("PORTAUDIO_PATH", "./portaudio-v19")

alternatively, you should be able to set PORTAUDIO_PATH env variable and get it to work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文