Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

ContexualVersionConflict When Importing Aiplatform Package in Executor of Vertex AI Workbench

Hi There,

I had the following problem when importing aiplatform package in executor of Vertex AI workbench. This issue did not occur when I manually run the code in the Vertex AI workbench. However, the error came when I set a executor to run my code on schedule.

---------------------------------------------------------------------------

Here is the script

from google.cloud import aiplatform

---------------------------------------------------------------------------

Here is the error message:

ContextualVersionConflict                 Traceback (most recent call last)
/tmp/ipykernel_295/605285511.py in <module>
     63 
     64 # Google cloud
---> 65 from google.cloud import aiplatform
     66 from datetime import datetime
     67 from google.cloud import bigquery

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform/__init__.py in <module>
     22 
     23 
---> 24 from google.cloud.aiplatform import initializer
     25 
     26 from google.cloud.aiplatform.datasets import (

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform/initializer.py in <module>
     29 from google.auth.exceptions import GoogleAuthError
     30 
---> 31 from google.cloud.aiplatform import compat
     32 from google.cloud.aiplatform.constants import base as constants
     33 from google.cloud.aiplatform import utils

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform/compat/__init__.py in <module>
     16 #
     17 
---> 18 from google.cloud.aiplatform.compat import services
     19 from google.cloud.aiplatform.compat import types
     20 

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform/compat/services/__init__.py in <module>
     16 #
     17 
---> 18 from google.cloud.aiplatform_v1beta1.services.dataset_service import (     19     client as dataset_service_client_v1beta1,
     20 )

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform_v1beta1/__init__.py in <module>
     15 #
     16 
---> 17 from .services.dataset_service import DatasetServiceClient
     18 from .services.dataset_service import DatasetServiceAsyncClient
     19 from .services.deployment_resource_pool_service import (

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform_v1beta1/services/dataset_service/__init__.py in <module>
     14 # limitations under the License.
     15 #
---> 16 from .client import DatasetServiceClient
     17 from .async_client import DatasetServiceAsyncClient
     18 

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform_v1beta1/services/dataset_service/client.py in <module>
     55 from google.protobuf import struct_pb2  # type: ignore
     56 from google.protobuf import timestamp_pb2  # type: ignore
---> 57 from .transports.base import DatasetServiceTransport, DEFAULT_CLIENT_INFO
     58 from .transports.grpc import DatasetServiceGrpcTransport
     59 from .transports.grpc_asyncio import DatasetServiceGrpcAsyncIOTransport

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/__init__.py in <module>
     17 from typing import Dict, Type
     18 
---> 19 from .base import DatasetServiceTransport
     20 from .grpc import DatasetServiceGrpcTransport
     21 from .grpc_asyncio import DatasetServiceGrpcAsyncIOTransport

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform_v1beta1/services/dataset_service/transports/base.py in <module>
     40     DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
     41         gapic_version=pkg_resources.get_distribution(
---> 42             "google-cloud-aiplatform",
     43         ).version,
     44     )

/opt/conda/lib/python3.7/site-packages/pkg_resources/__init__.py in get_distribution(dist)
    469         dist = Requirement.parse(dist)
    470     if isinstance(dist, Requirement):
--> 471         dist = get_provider(dist)
    472     if not isinstance(dist, Distribution):
    473         raise TypeError("Expected string, Requirement, or Distribution", dist)

/opt/conda/lib/python3.7/site-packages/pkg_resources/__init__.py in get_provider(moduleOrReq)
    345     """Return an IResourceProvider for the named module or requirement"""
    346     if isinstance(moduleOrReq, Requirement):
--> 347         return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
    348     try:
    349         module = sys.modules[moduleOrReq]

/opt/conda/lib/python3.7/site-packages/pkg_resources/__init__.py in require(self, *requirements)
    889         included, even if they were already activated in this working set.
    890         """
--> 891         needed = self.resolve(parse_requirements(requirements))
    892 
    893         for dist in needed:

/opt/conda/lib/python3.7/site-packages/pkg_resources/__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)
    780                 # Oops, the "best" so far conflicts with a dependency
    781                 dependent_req = required_by[req]
--> 782                 raise VersionConflict(dist, req).with_context(dependent_req)
    783 
    784             # push the new requirements onto the stack

ContextualVersionConflict: (google-cloud-bigquery 3.3.6 (/opt/conda/lib/python3.7/site-packages), Requirement.parse('google-cloud-bigquery<3.0.0dev,>=1.15.0'), {'google-cloud-aiplatform'})

-----------------------------------------------------------------------------------------------------

Seeking help from everyone. Thank you

 

 

3 REPLIES 3

It looks like you are encountering a version conflict error when trying to import the aiplatform package from Google Cloud. This error occurs when different versions of a package or its dependencies are installed and are being imported at the same time, which can cause conflicts.

One solution to this problem is to ensure that you have the correct versions of all required packages installed. You can check the version of the aiplatform package by running the following command:

pip show aiplatform

This will display the version of the package that is currently installed. If the version is not what you expected, you can try uninstalling and re-installing the package with the desired version using the following command:

pip install aiplatform==<desired_version>

Hi @Ram56 ,

Thanks for taking a look at this issue and the reply. I have tried your approach to upgrade the aiplatform package(!pip install google-cloud-aiplatform --upgrade), but still had the same issue. It seems that even we downgrade the google-cloud-bigquery package (!pip install google-cloud-bigquery==2.34.2 --user) to the version less than 3.0.0. The executor container would resume to be 3.4.1. which leads to the same issue again. Is there any other way you think worth a try ? Thank you

Cloud-BQ-Version 1.jpgCloud-BQ-Version 2.jpg

screenshots of my code