Skip to content

ImportError: No module named core.framework.graph_pb2 #61

Closed

Description

Compiled tensorflow from source, everything works including the eigen value computation example. However, when I try to run the mnist convolutional net example with the command 'python tensorflow/models/image/mnist/convolutional.py' I get the error: ImportError: No module named core.framework.graph_pb2.

Activity

  1. mrry commented on Nov 10, 2015

    @mrry
    Contributor

    For this to work, you'll have to install the PIP package. You can either download the pre-built package, or build it from source by following the instructions here: http://tensorflow.org/get_started/os_setup.md#create-pip

    If you've already installed the package, there might be some PYTHONPATH confusion due to your current working directory containing a directory called "tensorflow" without all of the generated protobuf files. One solution would be to cd into tensorflow/models/image/mnist and run python ./convolutional,py from there.

  2. vrv commented on Nov 10, 2015

    @vrv

    Yeah, this might be yet another instance of #51

    Given how often this is happening, I wonder if there's a better solution ...

  3. ghost closed this as completedon Nov 10, 2015
  4. alexryan commented on Nov 11, 2015

    @alexryan

    The suggested solution is to "install the PIP package:.
    I have done this but I still get this error.

    This statement is a little confusing ...
    "PYTHONPATH confusion due to your current working directory containing a directory called "tensorflow" without all of the generated protobuf files."
    ... because there are no .proto files in any tensorflow directory:

    $find . -name '*.proto'
    ./tensorflow/core/example/example.proto
    ./tensorflow/core/example/feature.proto
    ./tensorflow/core/framework/allocation_description.proto
    ./tensorflow/core/framework/attr_value.proto
    ./tensorflow/core/framework/config.proto
    ./tensorflow/core/framework/device_attributes.proto
    ./tensorflow/core/framework/function.proto
    ./tensorflow/core/framework/graph.proto
    ./tensorflow/core/framework/kernel_def.proto
    ./tensorflow/core/framework/op_def.proto
    ./tensorflow/core/framework/step_stats.proto
    ./tensorflow/core/framework/summary.proto
    ./tensorflow/core/framework/tensor.proto
    ./tensorflow/core/framework/tensor_description.proto
    ./tensorflow/core/framework/tensor_shape.proto
    ./tensorflow/core/framework/tensor_slice.proto
    ./tensorflow/core/framework/types.proto
    ./tensorflow/core/kernels/reader_base.proto
    ./tensorflow/core/lib/core/error_codes.proto
    ./tensorflow/core/util/event.proto
    ./tensorflow/core/util/saved_tensor_slice.proto
    ./tensorflow/python/training/checkpoint_state.proto
    ./tensorflow/python/training/saver.proto
    ./tensorflow/python/util/protobuf/compare_test.proto

    I tried the suggested work-around
    "cd into tensorflow/models/image/mnist and run python ./convolutional,py from there."
    This still gives me the error ...

    $python convolutional.py
    Traceback (most recent call last):
    File "convolutional.py", line 13, in
    import tensorflow.python.platform
    File "/Users/alexryan/projects/machineLearning/tensorFlow/clone/tensorflow/tensorflow/init.py", line 4, in
    from tensorflow.python import *
    File "/Users/alexryan/projects/machineLearning/tensorFlow/clone/tensorflow/tensorflow/python/init.py", line 13, in
    from tensorflow.core.framework.graph_pb2 import *
    ImportError: No module named core.framework.graph_pb2

    A solution to this would be very much appreciated.

  5. mrry commented on Nov 11, 2015

    @mrry
    Contributor

    @alexryan: It looks like the TensorFlow Python code is being loaded from the directory /Users/alexryan/projects/machineLearning/tensorFlow/clone/tensorflow/, which is an unusual path for the PIP installer to use. Did you also clone the git repository and add that directory to your PATH or PYTHONPATH environment variables? If so, try removing it - the problem arises because it tries to load from the unbuilt project source, which doesn't include the generated code for the protocol buffers (e.g. graph_pb2.py). If you have also installed it using PIP, it should be in your path already.

  6. alexryan commented on Nov 11, 2015

    @alexryan

    thank you.
    yes, I cloned the git repository to get access to the tutorial code.
    I had set the PYTHONPATH environment variable to include the tutorial code because I was getting this error:

    $python fully_connected_feed.py
    Traceback (most recent call last):
    File "fully_connected_feed.py", line 19, in
    from tensorflow.g3doc.tutorials.mnist import input_data
    ImportError: No module named g3doc.tutorials.mnist

    The tutorial source included these statements:
    #from tensorflow.g3doc.tutorials.mnist import input_data
    #from tensorflow.g3doc.tutorials.mnist import mnist

    It seems like python is trying to find these files in a different tensorflow directory.
    Changing the tutorial source to this solved the problem.
    import input_data
    import mnist

  7. added a commit that references this issue on Mar 9, 2016
    c1bf65f
  8. added a commit that references this issue on Mar 15, 2018
  9. added a commit that references this issue on Aug 1, 2019
    1415114
  10. added a commit that references this issue on May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions