Error: "Microsoft Visual C++ 14.0 is required" During PyAudio Installation on Windows
When attempting to install pyaudio on Windows, users may encounter the error: "error: Microsoft Visual C++ 14.0 is required." This error occurs because installing pyaudio requires Microsoft Visual C++ 14.0, also known as MSVC.
Solution:
To resolve this issue, follow these steps:
-
Determine your Python version: Execute the command python --version in a terminal or command prompt to check your Python version. This will help determine the appropriate MSVC redistributable package to download.
-
Download Microsoft Visual C++ 14.0 Redistributable: Navigate to the Microsoft website and download the MSVC redistributable package for your version of Windows.
-
Install MSVC Redistributable: Run the installer and follow the on-screen instructions to install the MSVC redistributable package.
-
Reinstall PyAudio: After successfully installing MSVC, you can now reinstall pyaudio using the following command:
python -m pip install PyAudio
登入後複製
-
Verify Installation: Once the installation is complete, import pyaudio in your Python script to verify if it's working properly.
Alternate Method (in case pip installation fails):
-
Download the PyAudio wheel file: Visit the PyAudio website and download the appropriate wheel file for your Python version and operating system (e.g., PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl).
-
Navigate to the downloaded file: Use the cd command in a terminal or command prompt to navigate to the directory where the wheel file is downloaded.
-
Install PyAudio using pip: Execute the following command to install PyAudio using the wheel file:
pip install path_to_wheel_file
登入後複製
For example, if your wheel file is located at ~/Downloads/PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl, the command would be:
pip install ~/Downloads/PyAudio‑0.2.11‑cp37‑cp37m‑win_amd64.whl
登入後複製
以上是為什麼在 Windows 上安裝 PyAudio 時會出現「需要 Microsoft Visual C 14.0」錯誤?的詳細內容。更多資訊請關注PHP中文網其他相關文章!