[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-02 (世界標準時間)。"],[],[],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)."]]