user3542259
user3542259

Reputation: 57

cannot import name 'aiplatform' from 'google_cloud_pipeline_components'

Working in Vertex on a Jupyter lab, I'm trying to import some libraries :

import kfp

from kfp import compiler, dsl
from kfp.dsl import component, pipeline, Artifact, ClassificationMetrics, Input, Output, Model, Metrics

from google.cloud import aiplatform
from google_cloud_pipeline_components import aiplatform as gcc_aip
from typing import NamedTuple

But doing so I have this message error :

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[4], line 7
      4 from kfp.dsl import component, pipeline, Artifact, ClassificationMetrics, Input, Output, Model, Metrics
      6 from google.cloud import aiplatform
----> 7 from google_cloud_pipeline_components import aiplatform as gcc_aip
      8 from typing import NamedTuple

ImportError: cannot import name 'aiplatform' from 'google_cloud_pipeline_components' (/home/jupyter/.local/lib/python3.10/site-packages/google_cloud_pipeline_components/__init__.py)

This is how I've installed the components

USER_FLAG = "--user"
!pip3 install {USER_FLAG} -U google-cloud-aiplatform "shapely<2"
!pip3 install {USER_FLAG} kfp google-cloud-pipeline-components --upgrade

I have no warning neither error message for the install.

I don't see what is missing ?

Regards

Upvotes: 1

Views: 1632

Answers (1)

krishr2d2
krishr2d2

Reputation: 64

The latest version(2.6.0) of gcpc has a lot of changes compared to the 1.x version. The aiplatform module itself is not available anymore but the service components it used to offer have been made available individually. For example, if you want to use the ModelUploadOp, you need to import it as from google_cloud_pipeline_components.v1.model import ModelUploadOp.

Upvotes: 3

Related Questions