简体   繁体   中英

PyAudio won't install: "fatal error: 'portaudio.h' file not found"

I have been trying to install PyAudio but I can't.

I have tried the Homebrew method and the Xcode method:

xcode-select --install
brew remove portaudio
brew install portaudio
pip3 install pyaudio

I even tried this command

pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio

I also tried

pip3 install pyaudio

and

pip install pyaudio

I keep getting this error

/Users/firassyed/opt/anaconda3/envs/env_pytorch/lib/python3.6/site-packages/pip/_internal/commands/install.py:245: UserWarning: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.
  cmdoptions.check_install_build_global(options)
Collecting pyaudio
  Using cached PyAudio-0.2.11.tar.gz (37 kB)
  Preparing metadata (setup.py) ... done
Skipping wheel build for pyaudio, due to binaries being disabled for it.
Installing collected packages: pyaudio
    Running setup.py install for pyaudio ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/firassyed/opt/anaconda3/envs/env_pytorch/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-pbxf5s_a/pyaudio_3976f98c4d7440d3bbb5800ecc3b675d/setup.py'"'"'; __file__='"'"'/private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-pbxf5s_a/pyaudio_3976f98c4d7440d3bbb5800ecc3b675d/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'"'"'))' build_ext -I/usr/local/include -L/usr/local/lib install --record /private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-record-i_lptc1z/install-record.txt --single-version-externally-managed --compile --install-headers /Users/firassyed/opt/anaconda3/envs/env_pytorch/include/python3.6m/pyaudio
         cwd: /private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-pbxf5s_a/pyaudio_3976f98c4d7440d3bbb5800ecc3b675d/
    Complete output (11 lines):
    running build_ext
    building '_portaudio' extension
    creating build
    creating build/temp.macosx-10.9-x86_64-3.6
    creating build/temp.macosx-10.9-x86_64-3.6/src
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/firassyed/opt/anaconda3/envs/env_pytorch/include -arch x86_64 -I/Users/firassyed/opt/anaconda3/envs/env_pytorch/include -arch x86_64 -DMACOSX=1 -I/usr/local/include -I/Users/firassyed/opt/anaconda3/envs/env_pytorch/include/python3.6m -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-3.6/src/_portaudiomodule.o
    src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
    #include "portaudio.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/firassyed/opt/anaconda3/envs/env_pytorch/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-pbxf5s_a/pyaudio_3976f98c4d7440d3bbb5800ecc3b675d/setup.py'"'"'; __file__='"'"'/private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-pbxf5s_a/pyaudio_3976f98c4d7440d3bbb5800ecc3b675d/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'"'"'))' build_ext -I/usr/local/include -L/usr/local/lib install --record /private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-record-i_lptc1z/install-record.txt --single-version-externally-managed --compile --install-headers /Users/firassyed/opt/anaconda3/envs/env_pytorch/include/python3.6m/pyaudio Check the logs for full command output.
Collecting pyaudio
  Using cached PyAudio-0.2.11.tar.gz (37 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pyaudio
  Building wheel for pyaudio (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/firassyed/opt/anaconda3/envs/env_pytorch/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-ozic18ff/pyaudio_0f1cab72b9cf407cb344f0b0fc90d0e4/setup.py'"'"'; __file__='"'"'/private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-ozic18ff/pyaudio_0f1cab72b9cf407cb344f0b0fc90d0e4/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'"'"'))' bdist_wheel -d /private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-wheel-rw8wdejj
       cwd: /private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-ozic18ff/pyaudio_0f1cab72b9cf407cb344f0b0fc90d0e4/
  Complete output (16 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.6
  copying src/pyaudio.py -> build/lib.macosx-10.9-x86_64-3.6
  running build_ext
  building '_portaudio' extension
  creating build/temp.macosx-10.9-x86_64-3.6
  creating build/temp.macosx-10.9-x86_64-3.6/src
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/firassyed/opt/anaconda3/envs/env_pytorch/include -arch x86_64 -I/Users/firassyed/opt/anaconda3/envs/env_pytorch/include -arch x86_64 -DMACOSX=1 -I/Users/firassyed/opt/anaconda3/envs/env_pytorch/include/python3.6m -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-3.6/src/_portaudiomodule.o
  src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
  #include "portaudio.h"
           ^~~~~~~~~~~~~
  1 error generated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pyaudio
  Running setup.py clean for pyaudio
Failed to build pyaudio
Installing collected packages: pyaudio
    Running setup.py install for pyaudio ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/firassyed/opt/anaconda3/envs/env_pytorch/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-ozic18ff/pyaudio_0f1cab72b9cf407cb344f0b0fc90d0e4/setup.py'"'"'; __file__='"'"'/private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-ozic18ff/pyaudio_0f1cab72b9cf407cb344f0b0fc90d0e4/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'"'"'))' install --record /private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-record-9pe8tglt/install-record.txt --single-version-externally-managed --compile --install-headers /Users/firassyed/opt/anaconda3/envs/env_pytorch/include/python3.6m/pyaudio
         cwd: /private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-ozic18ff/pyaudio_0f1cab72b9cf407cb344f0b0fc90d0e4/
    Complete output (18 lines):
    running install
    /Users/firassyed/opt/anaconda3/envs/env_pytorch/lib/python3.6/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      setuptools.SetuptoolsDeprecationWarning,
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.6
    copying src/pyaudio.py -> build/lib.macosx-10.9-x86_64-3.6
    running build_ext
    building '_portaudio' extension
    creating build/temp.macosx-10.9-x86_64-3.6
    creating build/temp.macosx-10.9-x86_64-3.6/src
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/firassyed/opt/anaconda3/envs/env_pytorch/include -arch x86_64 -I/Users/firassyed/opt/anaconda3/envs/env_pytorch/include -arch x86_64 -DMACOSX=1 -I/Users/firassyed/opt/anaconda3/envs/env_pytorch/include/python3.6m -c src/_portaudiomodule.c -o build/temp.macosx-10.9-x86_64-3.6/src/_portaudiomodule.o
    src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
    #include "portaudio.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/firassyed/opt/anaconda3/envs/env_pytorch/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-ozic18ff/pyaudio_0f1cab72b9cf407cb344f0b0fc90d0e4/setup.py'"'"'; __file__='"'"'/private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-install-ozic18ff/pyaudio_0f1cab72b9cf407cb344f0b0fc90d0e4/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'"'"'))' install --record /private/var/folders/j0/5j_xyczd6ddc5z2hm8wsbpwr0000gn/T/pip-record-9pe8tglt/install-record.txt --single-version-externally-managed --compile --install-headers /Users/firassyed/opt/anaconda3/envs/env_pytorch/include/python3.6m/pyaudio Check the logs for full command output.

Try:

pip install pipwin
pipwin install pyaudio

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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