Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Gunakan Vertex AI SDK untuk Python guna mengotomatiskan alur kerja machine learning (ML) Anda.
Topik ini menunjukkan cara menginstal Vertex AI SDK untuk Python. Untuk mengetahui
informasi selengkapnya tentang Vertex AI SDK, lihat referensi berikut:
Praktik terbaik Python adalah menginstal Vertex AI SDK di
lingkungan Python yang terisolasi untuk setiap project. Hal ini membantu mencegah konflik dependensi,
versi, dan izin. Anda dapat membuat lingkungan yang terisolasi untuk
menggunakan command line di shell atau untuk menggunakan notebook.
Untuk menggunakan notebook di lingkungan terisolasi, Anda dapat membuat instance Vertex AI Workbench. Kemudian, instal Vertex AI SDK
dan jalankan skrip Python dari notebook di instance Vertex AI Workbench Anda.
Untuk mengetahui informasi selengkapnya, lihat
Membuat instance Vertex AI Workbench.
Menginstal atau mengupdate paket Vertex AI SDK
Untuk menginstal atau mengupdate Vertex AI SDK, jalankan perintah berikut di
lingkungan virtual Anda:
pip install --upgrade google-cloud-aiplatform
Melakukan inisialisasi Vertex AI SDK
Setelah menginstal Vertex AI SDK untuk Python, Anda harus melakukan inisialisasi SDK dengan
detail Vertex AI dan Google Cloud . Misalnya, saat melakukan
inisialisasi SDK, Anda menentukan informasi seperti nama project, region,
dan bucket Cloud Storage staging. Metode berikut adalah contoh
metode yang melakukan inisialisasi Vertex AI SDK.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)."]]