Sam11
Sam11

Reputation: 73

ImportError: No module named 'google.protobuf' in Google Cloud AI Platform Jupyter Notebook

I am using a Google Colab AI Platform to train a model I tested on Jupyter notebook on my local computer. It did not create any import issue. But in the jupyterlab on Google Cloud, it fails to import protobuf.

I tried to test the imports in the SSH terminal of Google Cloud and it showed no import error.

I tried uninstalling and installing google and protobuf but the issue persists.

I tried creating an init.py file as suggested in [this][1] question but it did not solve the issue.

from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.layers import LSTM
from keras.optimizers import Adam
import numpy as np
import random
import sys
import os
import codecs
import collections
import _pickle as cPickle

Using TensorFlow backend. --------------------------------------------------------------------------- ImportError Traceback (most recent call last) in ----> 1 from keras.models import Sequential 2 from keras.layers import Dense, Activation 3 from keras.layers import LSTM 4 from keras.optimizers import Adam 5 import numpy as np

~/.local/lib/python3.5/site-packages/keras/init.py in 1 from future import absolute_import 2 ----> 3 from . import utils 4 from . import activations 5 from . import applications

~/.local/lib/python3.5/site-packages/keras/utils/init.py in 4 from . import data_utils 5 from . import io_utils ----> 6 from . import conv_utils 7 8 # Globally-importable utils.

~/.local/lib/python3.5/site-packages/keras/utils/conv_utils.py in 7 from six.moves import range 8 import numpy as np ----> 9 from .. import backend as K 10 11

~/.local/lib/python3.5/site-packages/keras/backend/init.py in 87 elif _BACKEND == 'tensorflow': 88 sys.stderr.write('Using TensorFlow backend.\n') ---> 89 from .tensorflow_backend import * 90 else: 91 # Try and load external backend.

~/.local/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py in 3 from future import print_function 4 ----> 5 import tensorflow as tf 6 from tensorflow.python.framework import ops as tf_ops 7 from tensorflow.python.training import moving_averages

~/.local/lib/python3.5/site-packages/tensorflow/init.py in 20 21 # pylint: disable=g-bad-import-order ---> 22 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import 23 24 try:

~/.local/lib/python3.5/site-packages/tensorflow/python/init.py in 50 51 # Protocol buffers ---> 52 from tensorflow.core.framework.graph_pb2 import * 53 from tensorflow.core.framework.node_def_pb2 import * 54 from tensorflow.core.framework.summary_pb2 import *

~/.local/lib/python3.5/site-packages/tensorflow/core/framework/graph_pb2.py in 4 import sys 5 _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) ----> 6 from google.protobuf import descriptor as _descriptor 7 from google.protobuf import message as _message 8 from google.protobuf import reflection as _reflection

ImportError: No module named 'google.protobuf'

[1]: No module named google.protobuf

Upvotes: 0

Views: 745

Answers (2)

Qubasa
Qubasa

Reputation: 183

You are missing the python package protobuf. Install it with:

pip install protobuf

Upvotes: 0

Sam11
Sam11

Reputation: 73

Nevermind importing google solved it.

import google

Upvotes: 1

Related Questions