Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Verwenden Sie das Vertex AI SDK für Python, um Ihre Workflows für maschinelles Lernen zu automatisieren.
In diesem Thema erfahren Sie, wie Sie das Vertex AI SDK für Python installieren. Weitere Informationen zum Vertex AI SDK finden Sie in den folgenden Ressourcen:
Eine Best Practice für Python besteht darin, das Vertex AI SDK pro Projekt in einer isolierten Python-Umgebung zu installieren. Das verhindert Konflikte in Sachen Abhängigkeiten, Versionen und Berechtigungen. Sie können eine isolierte Umgebung für die Verwendung der Befehlszeile in einer Shell oder zur Verwendung eines Notebooks erstellen.
Wenn Sie ein Notebook in einer isolierten Umgebung verwenden möchten, können Sie eine Vertex AI Workbench-Instanz erstellen. Installieren Sie dann das Vertex AI SDK und führen Sie Ihre Python-Skripts über ein Notebook auf Ihrer Vertex AI Workbench-Instanz aus.
Weitere Informationen finden Sie unter Vertex AI Workbench-Instanz erstellen.
Vertex AI SDK-Paket installieren oder aktualisieren
Führen Sie den folgenden Befehl in Ihrer virtuellen Umgebung aus, um das Vertex AI SDK zu installieren oder zu aktualisieren:
pip install --upgrade google-cloud-aiplatform
Vertex AI SDK initialisieren
Nachdem Sie das Vertex AI SDK für Python installiert haben, müssen Sie das SDK mit Ihren Vertex AI- und Google Cloud -Details initialisieren. Beispiel: Wenn Sie das SDK initialisieren, geben Sie Informationen wie Projektnamen, Region und Staging-Cloud Storage-Bucket an. Die folgende Methode ist ein Beispiel für eine Methode, mit der das Vertex AI SDK initialisiert wird.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-18 (UTC)."],[],[],null,["# Install the Vertex AI SDK for Python\n\nUse the Vertex AI SDK for Python to automate your machine learning (ML) workflows.\nThis topic shows you how to install the Vertex AI SDK for Python. For more\ninformation about the Vertex AI SDK, see the following resources:\n\n- To learn about the Vertex AI SDK for Python, see [Introduction to the Vertex AI SDK for Python](/vertex-ai/docs/python-sdk/use-vertex-ai-python-sdk).\n- To learn how to train a model using the Vertex AI SDK for Python, see the [Train\n a model using Vertex AI and the Python\n SDK](/vertex-ai/docs/tutorials/tabular-bq-prediction).\n- To learn about the classes and methods in the Vertex AI SDK for Python, see the [Vertex AI SDK reference](/python/docs/reference/aiplatform/latest/google.cloud.aiplatform).\n\nInstallation of the Vertex AI SDK for Python includes the following steps:\n\n1. [Create an isolated Python environment](#create-isolated-environment)\n2. [Install the Vertex AI SDK package](#install-python-sdk)\n3. [Initialize the Vertex AI SDK](#initialize-python-sdk)\n\nCreate an isolated Python environment\n-------------------------------------\n\nA Python best practice is to install the Vertex AI SDK in an\nisolated Python environment for each project. This helps prevent dependency,\nversion, and permissions conflicts. You can create an isolated environment for\nusing the command line in a shell or for using a notebook.\n\nTo create an isolated environment when you use the command line, [activate a\n`venv` environment](/python/docs/setup#installing_and_using_virtualenv). After\nthe `venv` environment is activated, you're ready to install the\nVertex AI SDK and run your Python scripts. For more information, see\n[Use `venv` to isolate dependencies](/python/docs/setup#installing_and_using_virtualenv)\nand [Set up a Python development environment](/python/docs/setup).\n\nTo use a notebook in an isolated environment, you can create a\nVertex AI Workbench instance. Then, install the Vertex AI SDK\nand run your Python scripts from a notebook on your Vertex AI Workbench instance.\nFor more information, see\n[Create a Vertex AI Workbench instance](/vertex-ai/docs/workbench/instances/create).\n\nInstall or update the Vertex AI SDK package\n-------------------------------------------\n\nTo install or update the Vertex AI SDK, run the following command in your\nvirtual environment: \n\n```\npip install --upgrade google-cloud-aiplatform\n```\n\nInitialize the Vertex AI SDK\n----------------------------\n\nAfter you install the Vertex AI SDK for Python, you must initialize the SDK with\nyour Vertex AI and Google Cloud details. For example, when you\ninitialize the SDK, you specify information such as your project name, region,\nand your staging Cloud Storage bucket. The following method is an example of\na method that initializes the Vertex AI SDK. \n\n def init_sample(\n project: Optional[str] = None,\n location: Optional[str] = None,\n experiment: Optional[str] = None,\n staging_bucket: Optional[str] = None,\n credentials: Optional[google.auth.credentials.Credentials] = None,\n encryption_spec_key_name: Optional[str] = None,\n service_account: Optional[str] = None,\n ):\n\n import https://cloud.google.com/python/docs/reference/vertexai/latest/\n\n https://cloud.google.com/python/docs/reference/vertexai/latest/.init(\n project=project,\n location=location,\n experiment=experiment,\n staging_bucket=staging_bucket,\n credentials=credentials,\n encryption_spec_key_name=encryption_spec_key_name,\n service_account=service_account,\n )\n\nWhat's next\n-----------\n\n- Learn more about the [Vertex AI SDK](/vertex-ai/docs/python-sdk/use-vertex-ai-python-sdk)."]]