0

Note: I am just starting out with ubuntu and python, I have extensive coding experience in other languages under windows.

So, I want to install this package:
https://github.com/google/protobuf/tree/master/python
I tried installing it in the following way: I tried downloading the code in this repository and then installing it. So first I downloaded the code using SVN:

svn checkout https://github.com/google/protobuf/trunk/python  

Then I tried installing it using:

sudo python setup.py install  

This gave the following output:

running install
running bdist_egg
running egg_info
creating protobuf.egg-info
writing requirements to protobuf.egg-info/requires.txt
writing protobuf.egg-info/PKG-INFO
writing namespace_packages to protobuf.egg-info/namespace_packages.txt
writing top-level names to protobuf.egg-info/top_level.txt
writing dependency_links to protobuf.egg-info/dependency_links.txt
writing manifest file 'protobuf.egg-info/SOURCES.txt'
reading manifest file 'protobuf.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files found matching 'google/protobuf/internal/*_pb2.py'
warning: no previously-included files found matching 'google/protobuf/internal/*.proto'
warning: no previously-included files matching '*_test.py' found under directory 'google'
warning: no previously-included files matching '*_test.proto' found under directory 'google'
warning: no previously-included files matching 'unittest*_pb2.py' found under directory 'google'
warning: no previously-included files matching '*.dll' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.so' found anywhere in distribution
writing manifest file 'protobuf.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
Generating google/protobuf/descriptor_pb2.py...
Can't find required file: ../src/google/protobuf/descriptor.proto

Manual inspection of my folders and of the original github confirmed that "descriptor.proto" was indeed not present. I did find lines 128-129 of setup.py:

# Generate necessary .proto file if it doesn't exist.
generate_proto("../src/google/protobuf/descriptor.proto")

So, I assume this file should have been created automatically, but wasn't for some reason. Does anyone know why?

edit:
I also tried just using:

sudo python setup.py build

This gave similarly:

running build
running build_py
Generating google/protobuf/descriptor_pb2.py...
Can't find required file: ../src/google/protobuf/descriptor.proto

edit 2: I now pulled the entire repository and rerun

sudo python setup.py build

This gave as output:

running build
running build_py
Generating google/protobuf/descriptor_pb2.py...
google/protobuf/descriptor.proto:381:3: Expected "required", "optional", or "repeated".
google/protobuf/descriptor.proto:381:12: Expected field name.
google/protobuf/descriptor.proto:439:3: Expected "required", "optional", or "repeated".
google/protobuf/descriptor.proto:439:12: Expected field name.
google/protobuf/descriptor.proto:537:3: Expected "required", "optional", or "repeated".
google/protobuf/descriptor.proto:537:12: Expected field name.

The corresponding lines in the descriptor.proto file are:
line 381:

reserved 38;  

line 439:

reserved 8;  // javalite_serializable  

line 537:

reserved 4;  // removed jtype  

These are also the only times this "reserved [number]" syntax is used, so I think this syntax might be the cause of the problem somehow. Does anyone have any ideas on this?

2
  • 1
    Did you try setup.py build or similar? – Grammargeek Dec 13 '16 at 2:16
  • Yes, this gave similar results. See edit – dimpol Dec 13 '16 at 2:22
2

So I got the answer from someone else, here is what finally worked for me:

First get a clean download of all the code (not only the python part as I initially did):

$ git clone https://github.com/google/protobuf.git

Then install some dependencies and compile:

$ cd protobuf/
$ apt-get install python-numpy python-scipy python-dev python-pip python-nose g++ libopenblas-dev git autoconf automake libtool curl make g++ unzip

Then follow src/README.md:

$ ./autogen.sh
$ ./configure
$ make
$ make check
$ sudo make install

Then install the python part, as described in python/README.md

$ cd python
$ python setup.py build
$ python setup.py test
$ python setup.py install
1

The problem is you only pulled part of the repository (protobuf/python), but the installation is looking for files in another directory (protobuf/src/google/protobuf/descriptor.proto)

So just pull in the complete repository:

$ git clone https://github.com/google/protobuf.git 

Then:

$ cd protobuf/python

And follow the installation instructions in README.md.

2
  • Thank you, this seemed to help me a step further. Unfortunately I am still having problems. Could you take a look at the latest edit of my main post? – dimpol Dec 13 '16 at 11:38
  • Maybe using a release is easier than compiling yourself: github.com/google/protobuf/releases – Timo Dec 14 '16 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.