I wanted to use the wonderful package caffe-tensorflow by ethereon and I ran into the same problem described in this closed issue:
When I run the example or try to import caffepb
I got the error message:
>>> import caffepb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "caffepb.py", line 28, in <module>
type=None),
File "/home/me/anaconda/python2.7/site-packages/google/protobuf/descriptor.py", line 652, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors should not be created directly, but only retrieved from their parent.
I am using Tensorflow 0.7.0 on a linux 64 bits UBUNTU 14.04 machine with protobuf 3.0.0b2.post (but it also happened with 3.0.0a4 and 3.0.0b2) with Python 2.7 and anaconda.
I tried to reinstall protobuf and tensorflow numerous times as I figured it was quite possibly a conflict between different protobuf installs (or at least that was the conclusion of the github issue) but I couldn't make it work even after doing a combination of pip install protobuf, pip uninstall protobuf or directly installing protobuf .whl.
What would you advise ?
EDIT: Using a virtual environment may be a solution but I would like to avoid it if possible
Renaming any file creating descriptors to have suffix "_pb2.py" will solve this problem.
UPDATE(April 4, 2017): In the "caffe-tensorflow" project, I renamed the "kaffe/caffe/caffepb.py" to "caffe_pb2.py", and this solved the problem. This is the only file I found in this project that creates PB descriptors.