Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems installing Python Protocol Buffers

I am a beginning programmer trying to install the Python Protocol Buffers from this package: http://code.google.com/p/protobuf/downloads/detail?name=protobuf-2.4.1.zip

The readme states:

1) Make sure you have Python 2.4 or newer. If in doubt, run:

 $ python -V

2) If you do not have setuptools installed, note that it will be downloaded and installed automatically as soon as you run setup.py. If you would rather install it manually, you may do so by following the instructions on this page:

 http://peak.telecommunity.com/DevCenter/EasyInstall#installation-instructions

3) Build the C++ code, or install a binary distribution of protoc. If you install a binary distribution, make sure that it is the same version as this package. If in doubt, run:

 $ protoc --version

4) Run the tests:

 $ python setup.py test

If some tests fail, this library may not work correctly on your system. Continue at your own risk.

Please note that there is a known problem with some versions of Python on Cygwin which causes the tests to fail after printing the error: "sem_init: Resource temporarily unavailable". This appears to be a bug either in Cygwin or in Python: http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html We do not know if or when it might me fixed. We also do not know how likely it is that this bug will affect users in practice.

5) Install:

 $ python setup.py install

This step may require superuser privileges. NOTE: To use C++ implementation, you need to install C++ protobuf runtime library of the same version and export the environment variable before this step. See the "C++ Implementation" section below for more details.


I have added both python and version 2.4.1 of protoc.exe into my PATH. However, when I try to run the test, I get an error message that says there's invalid syntax on line 38:

print "Can't find required file " + source

Okay, so it's missing parenthesis. I add them, and it encounters two more print statement syntax error messages. I fix those, and it encounters a syntax error message on an 'except' statement. What am I doing wrong?

Thanks.

like image 530
r123454321 Avatar asked Sep 08 '26 16:09

r123454321


2 Answers

Perhaps you are using Python 3?

The code you refer to will only work in Python 2.X

like image 166
jwd Avatar answered Sep 10 '26 06:09

jwd


I have followed same steps , but I didn't get any errors. Please make sure that you are getting correct Python and protoc version.

Export the environment LD_LIBRARY_PATH variable.

like image 36
snehal Avatar answered Sep 10 '26 05:09

snehal