Download the Library and Run the Sample

Follow these instructions to download the library and run the sample. Run all of the commands on this page in a terminal on your Raspberry Pi (either directly or via an SSH connection).

Configure a new Python virtual environment

Use a Python virtual environment to isolate the SDK and its dependencies from the system Python packages.

$ sudo apt-get update
$ sudo apt-get install python3-dev python3-venv
$ python3 -m venv env
$ env/bin/python -m pip install --upgrade pip setuptools
$ source env/bin/activate

Get the library and sample code

The Google Assistant SDK package contains all the code required to get the Google Assistant running on the Raspberry Pi, including the library and sample code.

Use pip to install the latest version of the Python package in the virtual environment:

(env) $ python -m pip install --upgrade google-assistant-library

Run the sample

Once you verify that everything is configured correctly, you can run the sample.

  1. On your development machine, open a browser and sign into the Google account you want to use to send queries to the Google Assistant. This can be any of your Google accounts, not just your developer account; just make sure that you set activity controls for the account.

  2. Authorize the Google Assistant SDK sample to make Google Assistant queries for the given Google Account. Reference the JSON file you copied over to the device in a previous step.

    # Install the authorization tool.
    (env) $ python -m pip install --upgrade google-auth-oauthlib[tool]

    # Run the tool.
    (env) $ google-oauthlib-tool --client-secrets /home/pi/client_secret_client-id.json --scope --save --headless

    • It should display as shown below. Copy the URL and paste it into a browser (this can be done on your development machine, or any other machine). After you approve, a code will appear in your browser, such as "4/XXXX". Copy this and paste this code into the terminal.

      Please go to this URL: https://...
      Enter the authorization code:
      • It should then display: OAuth credentials initialized.
      • If instead it displays: InvalidGrantError then an invalid code was entered. Try again, taking care to copy and paste the entire code.
  3. Start the Google Assistant SDK sample.

    (env) $ google-assistant-demo

  4. Say Ok Google or Hey Google, followed by your query. The Assistant should respond. If the Assistant does not respond, follow the troubleshooting instructions.


See the Troubleshooting page if you run into issues.

Next steps

You are now ready to start your own project:

$ git clone
$ cp -r assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/library new-project

See Next Steps for more information on customizing Google Assistant events and actions.