C3_W1_Lab_2 import error

Hello Learners,

I’m trying to run the second colab notebook from week 1 ‘C3_W1_Lab_2_TFX_Tuner_and_Trainer’ and the imports are not working. I’ve done as the notebooks says and restarted the runtime after the pip cell.

What shoud I do?

This is the error I keep getting:

/usr/local/lib/python3.7/dist-packages/tensorflow_serving/apis/status_pb2.py in <module>
     17 try:
---> 18   tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2 = tensorflow_dot_core_dot_protobuf_dot_error__codes__pb2.tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2
     19 except AttributeError:

AttributeError: module 'tensorflow.core.protobuf.error_codes_pb2' has no attribute 'tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
7 frames
/usr/local/lib/python3.7/dist-packages/tensorflow_serving/apis/status_pb2.py in <module>
     18   tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2 = tensorflow_dot_core_dot_protobuf_dot_error__codes__pb2.tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2
     19 except AttributeError:
---> 20   tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2 = tensorflow_dot_core_dot_protobuf_dot_error__codes__pb2.tensorflow.tsl.protobuf.error_codes_pb2
     21 
     22 

AttributeError: module 'tensorflow.core.protobuf.error_codes_pb2' has no attribute 'tensorflow'```
1 Like

Thanks for reporting this. I’ve notified the staff asking for a fix.

Hi Alexis! Welcome to the community and thank you for reporting! There was an issue with Colab’s tensorflow-serving-api package version and It has now been addressed. Kindly reopen the lab from the classroom and run it again. Thanks!

Hi Chris, the notebook “C3_W4_Lab_2_TFX_Evaluator” (Google Colab) got the same issue in the 2nd code cell.

After installing the needed libraries (1st code cell), I restarted the Runtime as required, but the issue persisted.

Here is the issue detail:


AttributeError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/tensorflow_serving/apis/status_pb2.py in
17 try:
—> 18 tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2 = tensorflow_dot_core_dot_protobuf_dot_error__codes__pb2.tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2
19 except AttributeError:

AttributeError: module ‘tensorflow.core.protobuf.error_codes_pb2’ has no attribute ‘tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2’

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
9 frames
/usr/local/lib/python3.7/dist-packages/tensorflow_serving/apis/status_pb2.py in
18 tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2 = tensorflow_dot_core_dot_protobuf_dot_error__codes__pb2.tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2
19 except AttributeError:
—> 20 tensorflow_dot_tsl_dot_protobuf_dot_error__codes__pb2 = tensorflow_dot_core_dot_protobuf_dot_error__codes__pb2.tensorflow.tsl.protobuf.error_codes_pb2
21
22

AttributeError: module ‘tensorflow.core.protobuf.error_codes_pb2’ has no attribute ‘tensorflow’

Here is the output of the library-installing cel (the 1st cell), useful for troubleshooting:

ERROR: pip’s legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.
apache-beam 2.43.0 requires requests<3.0.0,>=2.24.0, but you’ll have requests 2.23.0 which is incompatible.
tensorflow-serving-api 2.11.0 requires tensorflow<3,>=2.11.0, but you’ll have tensorflow 2.8.4 which is incompatible.
Successfully installed apache-beam-2.43.0 attrs-20.3.0 cachetools-4.2.4 cloudpickle-2.2.0 dill-0.3.1.1 docker-4.4.4 docopt-0.6.2 fastavro-1.7.0 fasteners-0.18 google-apitools-0.5.32 google-cloud-aiplatform-1.19.0 google-cloud-bigquery-2.34.4 google-cloud-bigquery-storage-2.13.2 google-cloud-bigtable-1.7.3 google-cloud-datastore-1.15.5 google-cloud-dlp-3.9.2 google-cloud-language-1.3.2 google-cloud-pubsub-2.13.11 google-cloud-pubsublite-1.6.0 google-cloud-recommendations-ai-0.7.1 google-cloud-resource-manager-1.6.3 google-cloud-spanner-3.23.0 google-cloud-videointelligence-1.16.3 google-cloud-vision-1.0.2 grpc-google-iam-v1-0.12.4 hdfs-2.7.0 jedi-0.18.2 joblib-0.14.1 keras-2.8.0 keras-tuner-1.1.3 kt-legacy-1.0.4 kubernetes-12.0.1 ml-metadata-1.7.0 ml-pipelines-sdk-1.7.0 objsize-0.5.2 orjson-3.8.2 overrides-6.5.0 packaging-20.9 pyarrow-5.0.0 pyfarmhash-0.3.2 pymongo-3.13.0 pyyaml-5.4.1 tensorboard-2.8.0 tensorflow-2.8.4 tensorflow-data-validation-1.7.0 tensorflow-estimator-2.8.0 tensorflow-metadata-1.7.0 tensorflow-model-analysis-0.38.0 tensorflow-serving-api-2.11.0 tensorflow-transform-1.7.0 tfx-1.7.0 tfx-bsl-1.7.0 websocket-client-1.4.2 zstandard-0.19.0
WARNING: Running pip as the ‘root’ user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: 12. Virtual Environments and Packages — Python 3.12.0 documentation

Hi Tran! Thank you for reporting! We’ve added the required version of the tensorflow-serving-api and the Colab now runs as expected. Kindly re-open it from your classroom to see the revision. Hope it also works on your end. Thanks again!