[Solved] Python 3.8 Install pyaudio Error: pip3 install pyaudio error: Microsoft Visual C++ 14.0 or greater is required.

E:\Eprogramfiles\Anaconda3\envs\myenvpy38>pip3 install pyaudio
Collecting pyaudio
Using cached PyAudio-0.2.11.tar.gz (37 kB)
Using legacy 'setup.py install' for pyaudio, since package 'wheel' is not installed.
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python38\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-m6oeci17\\pyaudio_c8557100e30446cabb941c1c6428849d\\setup.py'"'"'; __file__='"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-m6oeci17\\pyaudio_c8557100e30446cabb941c1c6428849d\\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 'C:\Users\Administrator\AppData\Local\Temp\pip-record-49wse8x_\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\python38\Include\pyaudio'
cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-m6oeci17\pyaudio_c8557100e30446cabb941c1c6428849d\
Complete output (9 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.8
copying src\pyaudio.py -> build\lib.win-amd64-3.8
running build_ext
building '_portaudio' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python38\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-m6oeci17\\pyaudio_c8557100e30446cabb941c1c6428849d\\setup.py'"'"'; __file__='"'"'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-m6oeci17\\pyaudio_c8557100e30446cabb941c1c6428849d\\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 'C:\Users\Administrator\AppData\Local\Temp\pip-record-49wse8x_\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\python38\Include\pyaudio' Check the logs for full command output.
WARNING: You are using pip version 21.1.1; however, version 21.3.1 is available.
You should consider upgrading via the 'c:\python38\python.exe -m pip install --upgrade pip' command.

========================================================
reason:
It has nothing to do with whether Visual C++ 14.0 or greater is installed.


========================================================

Solution:
Pyaudio installed directly with pip does not support 3.7, so an error will be reported during installation or import.
So directly download the whl file and install it.

whl download address:
https://github.com/intxcc/pyaudio_portaudio/releases

Switch to the whl file directory and install directly with pip

pip install PyAudio-0.2.11-cp37-cp37m-win_amd64.whl

>>> import pyaudio
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Administrator\PycharmProjects\untitled\venv\lib\site-packages\pyaudio.py", line 116, in <module>
import _portaudio as pa
ModuleNotFoundError: No module named '_portaudio'

C:\Users\Administrator\PycharmProjects\untitled\venv\Scripts>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyaudio
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Administrator\PycharmProjects\untitled\venv\lib\site-packages\pyaudio.py", line 116, in <module>
import _portaudio as pa
ModuleNotFoundError: No module named '_portaudio'
>>>

The official PyAudio 0.2.11 does not support Python 3.7+, and trying to install results in the error C1083: Cannot open include file: 'portaudio.h'. However, there are unofficial wheels for PyAudio that support 3.7+. If you are using the official version, you must use Python 3.6 with PyAudio 0.2.11. See http://people.csail.mit.edu/hubert/pyaudio/ pip will fetch and install PyAudio wheels (prepackaged binaries). Currently, there are wheels compatible with the official distributions of Python 2.7, 3.4, 3.5, and 3.6. http://people.csail.mit.edu/hubert/pyaudio/

Similar Posts: