How to Install PyAudio in Visual Studio Code

PyAudio provides Python bindings for PortAudio, the cross-platform audio I/O library. This allows you to use PyAudio to record and play sound on various platforms and operating systems such as Windows, Mac, and Linux. There are two ways to install PyAudio in Visual Studio Code. You can run pip commands in the command line or install the wheel package. This guide will show you both methods.

Installing PyAudio using the pip command

In this method, we run two pip commands in the command line to install PyAudio. Do the following:

  1. Open the command line in your respective operating system:
    Command Prompt on Windows and Linux
    Terminal on Mac OS.
  2. Run the following two commands:
    pip install pipwin
    pipwin install pyaudio

    pip commands
    Execute the given two commands.

  3. To check if the installation is successful, open the terminal in VS Code.

    Terminal
    Open the Terminal in VS Code.

  4. Run the following command in the terminal:
    pip install PyAudio

    Pyaudio Command
    Execute the following code in the terminal: pip install PyAudio.

  5. The installation is successful if the output shows “Requirement already satisfied”

    Successful Installation
    You’ll be prompted with a “Requirement already satisfied” statement.

Installing PyAudio using wheel

Wheel is a python package or library which contains the PyAudio module. Follow the steps below to install PyAudio using wheel:

  1. Firstly, check the version of python installed in your system. To do that, run the following command in the command line:
    python

    Python Version
    Type “python” in the command line and hit Enter.

  2. Head over to this website: lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
  3. Press Ctrl + F to open the search bar and type “PyAudio”. Download the correct version of the Python wheel according to the python version and python architecture highlighted in the above image. Here I will choose 3.10 and 64 bit.

    Download PyAudio
    Download the PyAudio file according to your python version and python architecture.

  4. Right-click on the downloaded file and select the Properties option.

    Properties
    Right-click on the downloaded file and select the Properties option.

  5. Select the location and press Ctrl + C to copy.

    Path
    Copy the location.

  6. Open the command line and type “pip install”. Then, paste the copied path followed by the downloaded file’s name. This is what the command looks like according to my system:
    pip install C:UsersgauraDownloadsPyAudio-0.2.11-cp310-cp310-win_amd64.whl

    pip wheel command
    In the command line, type “pip install”, followed by the path of the downloaded file.

  7. To check if the installation is successful, open the terminal in VS Code.

    Terminal
    Open the Terminal in VS Code.

  8. Run the following command in the terminal:
    pip install PyAudio

    Pyaudio Command
    Execute the following code in the terminal: pip install PyAudio.

  9. The installation is successful if the output shows “Requirement already satisfied”

    Successful Installation
    You’ll be prompted with a “Requirement already satisfied” statement.

Leave a Comment