Hi, I am following this tutorial on model deployment (https://codelabs.developers.google.com/vertex-image-deploy#6), but I ran into a issue when importing the aiplatform library.
When running "from google.cloud import aiplatform", I get the following error message:
ImportError Traceback (most recent call last) /tmp/ipykernel_22080/3236611779.py in <module> 4 #!python #3.7.12 5 ----> 6 from google.cloud import aiplatform 7 8 import tensorflow as tf /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> 24 25 from google.api_core import client_options ---> 26 from google.api_core import gapic_v1 27 import google.auth 28 from google.auth import credentials as auth_credentials /opt/conda/lib/python3.7/site-packages/google/api_core/gapic_v1/__init__.py in <module> 17 from google.api_core.gapic_v1 import config_async 18 from google.api_core.gapic_v1 import method ---> 19 from google.api_core.gapic_v1 import method_async 20 from google.api_core.gapic_v1 import routing_header 21 /opt/conda/lib/python3.7/site-packages/google/api_core/gapic_v1/method_async.py in <module> 20 import functools 21 ---> 22 from google.api_core import grpc_helpers_async 23 from google.api_core.gapic_v1 import client_info 24 from google.api_core.gapic_v1.method import _GapicCallable /opt/conda/lib/python3.7/site-packages/google/api_core/grpc_helpers_async.py in <module> 23 24 import grpc ---> 25 from grpc import aio 26 27 from google.api_core import exceptions, grpc_helpers /opt/conda/lib/python3.7/site-packages/grpc/aio/__init__.py in <module> 21 22 import grpc ---> 23 from grpc._cython.cygrpc import (init_grpc_aio, shutdown_grpc_aio, EOF, 24 AbortError, BaseError, InternalError, 25 UsageError) ImportError: cannot import name 'shutdown_grpc_aio' from 'grpc._cython.cygrpc' (/opt/conda/lib/python3.7/site-packages/grpc/_cython/cygrpc.cpython-37m-x86_64-linux-gnu.so)
The versions of the concerned libraries are shown below.
google-api-core 2.10.1 google-api-python-client 2.55.0 google-cloud-aiplatform 1.17.0 grpcio 1.33.1 grpcio-gcp 0.2.2 grpcio-status 1.47.0
I have tried grpcio versions 1.26, 1.27.2, and even the latest 1.50, but all of them had import errors (concerning importing of aio module for 1.26 and 127.2 and AbortError module for 1.50). Are there any additional steps or libraries that I need to take to avoid these import errors?
Thank you!
Solved! Go to Solution.
Hi, thank you for your reply. I am running the code on Vertex AI.
I realised I had to restart the kernel to refresh the package after updating grpcio, and I could then import aiplatform without any issues as shown below:
from google.cloud import aiplatform
print("aiplatform version: ", aiplatform.__version__)
aiplatform version: 1.17.0
Thanks again for your help!
Hi,
I tried the code labs link and I did not encounter your error. I ran the code in a "Managed Notebook" as shown in the labs. Here are the versions of the libraries in my notebook:
google-api-core == 2.8.0
google-api-python-client == 2.65.0
google-cloud-aiplatform == 1.18.2
grpcio == 1.50.0
grpcio-gcp == 0.2.2
grpcio-status == 1.48.2
Just to confirm, where did you run the code?
Hi, thank you for your reply. I am running the code on Vertex AI.
I realised I had to restart the kernel to refresh the package after updating grpcio, and I could then import aiplatform without any issues as shown below:
from google.cloud import aiplatform
print("aiplatform version: ", aiplatform.__version__)
aiplatform version: 1.17.0
Thanks again for your help!
You can mark this as solved so future readers can easily determine the solution.
in process ImportError: cannot import name 'aiplatform' from 'google.cloud' this error I am getting while I am importing it into apache beam- dataflow pipeline
@ricconoel can you help me here
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |