簡體   English   中英

在 Mac M1 上安裝 PyAudio 很困難

[英]Difficulty installing PyAudio on Mac M1

請注意,Stack Overflow 上已經提供的答案對我不起作用。 包括但不僅限於:

brew update
brew install portaudio
brew link --overwrite portaudio
pip install pyaudio

我可以從真正願意提供幫助的人那里得到一些幫助。

當我運行上述函數時,一切正常,直到我點擊pip install pyaudio行,然后出現以下錯誤:

WARNING: Discarding https://files.pythonhosted.org/packages/d0/dc/ffb9ce5e3f19bd289902915a9f68b7d199216065f8ea17d5b5e8e4ad86ee/PyAudio-0.2.9.tar.gz#sha256=bfd694272b3d1efc51726d0c27650b3c3ba1345f7f8fdada7e86c9751ce0f2a1 (from https://pypi.org/simple/pyaudio/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached pyaudio-0.2.8.tar.gz (235 kB)
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/lw/_gcm85s107z9sbgqyrw5pw700000gn/T/pip-install-vvvb_ho8/pyaudio_ebec704a423648cfb3b175c8def295f6/setup.py'"'"'; __file__='"'"'/private/var/folders/lw/_gcm85s107z9sbgqyrw5pw700000gn/T/pip-install-vvvb_ho8/pyaudio_ebec704a423648cfb3b175c8def295f6/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/lw/_gcm85s107z9sbgqyrw5pw700000gn/T/pip-pip-egg-info-j7szc61a
       cwd: /private/var/folders/lw/_gcm85s107z9sbgqyrw5pw700000gn/T/pip-install-vvvb_ho8/pyaudio_ebec704a423648cfb3b175c8def295f6/
  Complete output (15 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/lw/_gcm85s107z9sbgqyrw5pw700000gn/T/pip-install-vvvb_ho8/pyaudio_ebec704a423648cfb3b175c8def295f6/setup.py", line 124, in <module>
      setup(name = 'PyAudio',
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/core.py", line 121, in setup
      dist.parse_config_files()
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 796, in parse_config_files
      self._parse_config_files(filenames=filenames)
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 664, in _parse_config_files
      parser.read_file(reader)
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/configparser.py", line 719, in read_file
      self._read(f, source)
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/configparser.py", line 1097, in _read
      raise DuplicateOptionError(sectname, optname,
  configparser.DuplicateOptionError: While reading from '/Users/evvolvx/.pydistutils.cfg' [line  3]: option 'include_dirs' in section 'build_ext' already exists
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/06/d1/3d202c9187fb78ad6d4f8b476a8cc0ded7c1b47ca33d5dab73b959faf123/pyaudio-0.2.8.tar.gz#sha256=4f85367cf79657616684487037957ac38582ecc5389b89420fe61d901b719551 (from https://pypi.org/simple/pyaudio/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement pyaudio (from versions: 0.2.8, 0.2.9, 0.2.10, 0.2.11)
ERROR: No matching distribution found for pyaudio

任何幫助將不勝感激。 謝謝

這是我對 Stack Overflow 的第一次回應,所以請原諒我缺乏清晰性。 我嘗試在 Apple Silicon 上使用 Python3.10 pip 運行它,並注意到安裝程序嘗試從源代碼構建模塊。 您應該在完整的錯誤消息中看到像這樣的 output。

Complete output (16 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 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -DMACOSX=1 -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/opt/python@3.9/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:29:10: fatal error: 'portaudio.h' file not found
  #include "portaudio.h"
           ^~~~~~~~~~~~~
  1 error generated.
  error: command '/usr/bin/clang' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for pyaudio

我在安裝 psycopg2 時遇到了這個問題,當我將它安裝為預構建的二進制文件時,沒有問題。

在我寫這篇回復的時候,在 Apple Silicon 上從源代碼編譯是不支持的,比如 PIL 等一些模塊,它需要原生構建,沒有它就無法運行。 據我所知,以下是您的選擇:

  1. 手動下載輪子,想辦法編譯(不推薦)
  2. 安裝為 Apple Silicon 制作的預構建二進制文件(我知道不存在)
  3. 安裝兼容 Rosetta 的 64 位 pyaudio 構建(最簡單)

這個問題有一些有用的回答,描述了安裝 64 位版本的過程。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM