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 more information about the Vertex AI SDK, see the following resources:
- To learn about the Vertex AI SDK for Python, see Introduction to the Vertex AI SDK for Python.
- To learn how to train a model using the Vertex AI SDK for Python, see the Train a model using Vertex AI and the Python SDK.
- To learn about the classes and methods in the Vertex AI SDK for Python, see the vertex_ai_sdk_for_python_ref_name.
Installation of the Vertex AI SDK for Python includes the following steps:
- Create an isolated Python environment
- Install the Vertex AI SDK package
- Initialize the Vertex AI SDK
Create an isolated Python environment
A Python best practice is to install the Vertex AI SDK in an isolated Python environment for each project. This helps prevent dependency, version, and permissions conflicts. You can create an isolated environment for using the command line in a shell or for using a notebook.
To create an isolated environment when you use the command line, activate a
venv
environment. After
the venv
environment is activated, you're ready to install the
Vertex AI SDK and run your Python scripts. For more information, see
Use venv
to isolate dependencies
and Set up a Python development environment.
To use a notebook for your isolated environment, create a notebook instance. After you create your notebook instance, use it to install the Vertex AI SDK and run your Python scripts. For more information, see Create a user-managed notebooks instance.
Install or update the Vertex AI SDK package
To install or update the Vertex AI SDK, run the following command in your virtual 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 with your Vertex AI and Google Cloud details. For example, when you initialize the SDK, you specify information such as your project name, region, and your staging Cloud Storage bucket. The following method is an example of a method that initializes the Vertex AI SDK.
What's next
- Learn more about the Vertex AI SDK.