Install the Vertex AI SDK for Python

Use the Vertex AI SDK for Python to automate your machine learning (ML) workflows.This topic shows you how to install the Vertex AI SDK for Python. For moreinformation about the Vertex AI SDK, see the following resources:

Installation of the Vertex AI SDK for Python includes the following steps:

  1. Create an isolated Python environment
  2. Install the Vertex AI SDK package
  3. Initialize the Vertex AI SDK

Create an isolated Python environment

A Python best practice is to install the Vertex AI SDK in anisolated Python environment for each project. This helps prevent dependency,version, and permissions conflicts. You can create an isolated environment forusing the command line in a shell or for using a notebook.

To create an isolated environment when you use the command line,activate avenv environment. Afterthevenv environment is activated, you're ready to install theVertex AI SDK and run your Python scripts. For more information, seeUsevenv to isolate dependenciesandSet up a Python development environment.

To use a notebook in an isolated environment, you can create aVertex AI Workbench instance. Then, install the Vertex AI SDKand run your Python scripts from a notebook on your Vertex AI Workbench instance.For more information, seeCreate a Vertex AI Workbench instance.

Install or update the Vertex AI SDK package

To install or update the Vertex AI SDK, run the following command in yourvirtual environment:

pip install --upgrade google-cloud-aiplatform

Initialize the Vertex AI SDK

After you install the Vertex AI SDK for Python, you must initialize the SDK withyour Vertex AI and Google Cloud details. For example, when youinitialize the SDK, you specify information such as your project name, region,and your staging Cloud Storage bucket. The following method is an example ofa method that initializes the Vertex AI SDK.

definit_sample(project:Optional[str]=None,location:Optional[str]=None,experiment:Optional[str]=None,staging_bucket:Optional[str]=None,credentials:Optional[google.auth.credentials.Credentials]=None,encryption_spec_key_name:Optional[str]=None,service_account:Optional[str]=None,):importvertexaivertexai.init(project=project,location=location,experiment=experiment,staging_bucket=staging_bucket,credentials=credentials,encryption_spec_key_name=encryption_spec_key_name,service_account=service_account,)

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-17 UTC.