简体   繁体   English

在 macOS Big Sur 上安装 pyaudio 时出错

[英]Error in installing pyaudio on macOS Big Sur

Recently, I needed pyaudio, which I could easily install on a Linux machine.最近,我需要 pyaudio,我可以轻松地将其安装在 Linux 机器上。 But my main computer runs macOS and I needed to run the same code here on my mac.但是我的主计算机运行 macOS,我需要在我的 mac 上运行相同的代码。 I just did this:我只是这样做了:

sudo pip3 install pyaudio

And I got these errors:我得到了这些错误:

 ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/python@3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-y40lwe0s/pyaudio_a8cc0acc22ad46cc862ce836313544b3/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-y40lwe0s/pyaudio_a8cc0acc22ad46cc862ce836313544b3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/tmp/pip-wheel-o2h5vchr
       cwd: /private/tmp/pip-install-y40lwe0s/pyaudio_a8cc0acc22ad46cc862ce836313544b3/
  Complete output (60 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-11-x86_64-3.9
  copying src/pyaudio.py -> build/lib.macosx-11-x86_64-3.9
  running build_ext
  building '_portaudio' extension
  creating build/temp.macosx-11-x86_64-3.9
  creating build/temp.macosx-11-x86_64-3.9/src
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DMACOSX=1 -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python@3.9/3.9.0_4/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/_portaudiomodule.c -o build/temp.macosx-11-x86_64-3.9/src/_portaudiomodule.o
  src/_portaudiomodule.c:2278:3: warning: 'PyEval_InitThreads' is deprecated [-Wdeprecated-declarations]
    PyEval_InitThreads();
    ^
  /usr/local/Cellar/python@3.9/3.9.0_4/Frameworks/Python.framework/Versions/3.9/include/python3.9/ceval.h:130:1: note: 'PyEval_InitThreads' has been explicitly marked deprecated here
  Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
  ^
  /usr/local/Cellar/python@3.9/3.9.0_4/Frameworks/Python.framework/Versions/3.9/include/python3.9/pyport.h:508:54: note: expanded from macro 'Py_DEPRECATED'
  #define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                       ^
  1 warning generated.
  clang -bundle -undefined dynamic_lookup build/temp.macosx-11-x86_64-3.9/src/_portaudiomodule.o -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/sqlite/lib -lportaudio -o build/lib.macosx-11-x86_64-3.9/_portaudio.cpython-39-darwin.so
  installing to build/bdist.macosx-11-x86_64/wheel
  running install
  running install_lib
  creating build/bdist.macosx-11-x86_64
  creating build/bdist.macosx-11-x86_64/wheel
  copying build/lib.macosx-11-x86_64-3.9/_portaudio.cpython-39-darwin.so -> build/bdist.macosx-11-x86_64/wheel
  copying build/lib.macosx-11-x86_64-3.9/pyaudio.py -> build/bdist.macosx-11-x86_64/wheel
  running install_egg_info
  running egg_info
  writing src/PyAudio.egg-info/PKG-INFO
  writing dependency_links to src/PyAudio.egg-info/dependency_links.txt
  writing top-level names to src/PyAudio.egg-info/top_level.txt
  reading manifest file 'src/PyAudio.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  writing manifest file 'src/PyAudio.egg-info/SOURCES.txt'
  Copying src/PyAudio.egg-info to build/bdist.macosx-11-x86_64/wheel/PyAudio-0.2.11-py3.9.egg-info
  running install_scripts
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/tmp/pip-install-y40lwe0s/pyaudio_a8cc0acc22ad46cc862ce836313544b3/setup.py", line 106, in <module>
      setup(name='PyAudio',
    File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "/usr/local/Cellar/python@3.9/3.9.0_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/Cellar/python@3.9/3.9.0_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/local/Cellar/python@3.9/3.9.0_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 337, in run
      impl_tag, abi_tag, plat_tag = self.get_tag()
    File "/usr/local/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 260, in get_tag
      plat_name = get_platform(self.bdist_dir)
    File "/usr/local/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 52, in get_platform
      result = calculate_macosx_platform_tag(archive_root, result)
    File "/usr/local/lib/python3.9/site-packages/wheel/macosx_libfile.py", line 356, in calculate_macosx_platform_tag
      assert len(base_version) == 2
  AssertionError
  ----------------------------------------
  ERROR: Failed building wheel for pyaudio

I updated python and also I updated XCode to get it to work, but it didn't do anything and I still get the errors.我更新了 python 并且我更新了 XCode 让它工作,但它没有做任何事情,我仍然得到错误。 The same thing happened with a bunch of libraries, but I think if I solve problems I have here, others will be okay too.一堆图书馆也发生了同样的事情,但我认为如果我解决了我在这里遇到的问题,其他人也会好起来的。

I also get the errors like these today, and I solved it through the brew tool to install the portaudio .我今天也遇到这样的错误,我通过brew工具安装了portaudio解决了它。

brew install portaudio
pip install pyaudio

It works for me, so I think this may be of help to you...它对我有用,所以我认为这可能对你有帮助......

Collecting pyaudio
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz (37 kB)
Building wheels for collected packages: pyaudio
  Building wheel for pyaudio (setup.py) ... done
  Created wheel for pyaudio: filename=PyAudio-0.2.11-cp39-cp39-macosx_10_15_x86_64.whl size=23705 sha256=56e3a3fde06040f875ef5de2973fe474f6c83624524bc3ec76de55599a253b66
  Stored in directory: /Users/dapeng/Library/Caches/pip/wheels/2f/bd/fe/e61f992b5c64b27ac4dd31c3af467a800178eafba6fcb15815
Successfully built pyaudio
Installing collected packages: pyaudio
Successfully installed pyaudio-0.2.11

The problem solved very easily.这个问题很容易解决。 Just needed to install python from python.org and not brew .只需要从 python.org 安装 python 而不是brew

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM