Tensorflow: from google.protobuf import descriptor as _descriptor ImportError: No module named google.protobuf

Created on 28 Jun 2016  ·  3Comments  ·  Source: tensorflow/tensorflow

Hey guys I'm working on a project using tensorflow on the Amazon Web Services microservices platform and I've run into a few problems. I installed tensorflow using pip into a virtualenv. Then I took the contents of /env/lib/python2.7/site-packages/ and zipped it along with my source code into a development package for AWS Lambda (env is the name of my virtualenv). This is the process for using python libraries for an AWS Lambda process and I haven't run into any problems with other libraries. I've done this for numpy,scipy,Pillow, and a bunch of other far less supported libraries and they have all worked fine with Lambda.

However when I attempt to use tensorflow it returns this:

Unable to import module 'classify': Traceback (most recent call last): File "/var/task/tensorflow/python/__init__.py", line 52, in from tensorflow.core.framework.graph_pb2 import * File "/var/task/tensorflow/core/framework/graph_pb2.py", line 6, in from google.protobuf import descriptor as _descriptor ImportError: No module named google.protobuf Error importing tensorflow. Unless you are using bazel, you should not try to import tensorflow from its source directory; please exit the tensorflow source tree, and relaunch your python interpreter from there.

classify is the source script AWS Lambda calls when it is invoked and was zipped along with the contents of /env/lib/python2.7/site-packages/ as I described.

These errors have been addressed a couple of other places but none of the solutions I found on those pages have worked for me, probably because none of them were using lambda. Is it possible that tensorflow just will not work with lambda because of the way lambda imports libraries? If so is there anyway import the tensorflow package from just a source folder that I upload as a zip?

Specific Steps to Reproduce:

It's occurred to me that this probably isn't something tensorflow is probably supporting given that most people aren't using tensorflow inside AWS containers but hopefully someone can help or at least give it their best shot even if they don't specifically have experience with AWS.

Thanks!!

Most helpful comment

Okay I have no idea what this does but it fixed this whole issue::

cd into site-packages
touch google/__init__.py
do this before you zip up site-packages
^bash

All 3 comments

Okay I have no idea what this does but it fixed this whole issue::

cd into site-packages
touch google/__init__.py
do this before you zip up site-packages
^bash

That is fascinating. I have no idea what the problem is, but it may be endemic to AWS lambda. I'll close this issue.

Stumbled over this on my travels. It's not Lambda, it's the protobuf module: https://github.com/google/protobuf/issues/1296

Was this page helpful?
0 / 5 - 0 ratings