Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Python 3 SyntaxError #882

Closed
dvenza opened this issue Oct 14, 2015 · 7 comments
Closed

Python 3 SyntaxError #882

dvenza opened this issue Oct 14, 2015 · 7 comments
Assignees

Comments

@dvenza
Copy link

dvenza commented Oct 14, 2015

After doing a pip3 install protobuf, when I try to use the package I get this SyntaxError:

File "/usr/local/lib/python3.4/dist-packages/google/protobuf/reflection.py", line 68, in <module>
    from google.protobuf.internal import python_message
File "/usr/local/lib/python3.4/dist-packages/google/protobuf/internal/python_message.py", line 848
    except struct.error, e:

Why there is a package for python3, if python3 is not supported?

@MH-L
Copy link

MH-L commented Oct 18, 2015

Is this the full stack trace? What is the error message of the exception?

@nongiach
Copy link

it's not a exception, it's syntax error !!! it should be "except (struct.error, e):" , I tried to correct it myself but there are too many error of syntax (syntax python2 in python3 package). Thx to fix it plz

@dvenza
Copy link
Author

dvenza commented Oct 23, 2015

You can manually convert with 2to3 all the files by hand, but why is this package advertised as python 3 compatible and why is it available via pip for python 3?

@nmoadev
Copy link

nmoadev commented Jan 8, 2016

This issue happens for me too. Simple test is to confirm is just to run a compiled protocol buffer python file directly. Same syntax error occurs. Pip freeze shows 'protobuf==2.6.1'

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Jan 8, 2016

That last stable release (2.6.1) doesn't support python3. For python3, you need to install the latest beta versions:

$ pip3 install protobuf==3.0.0b2

Since it's beta, it's not automatically picked up by "pip3 instal protobuf" and you need to set the version number explicitly.

@ghost
Copy link

ghost commented Jun 5, 2016

Yes there is a lot of syntax errors, if you don't want to handle yourself use python2

@ZubairKhan001
Copy link

i have compiled caffe on Ubuntu 16.04 LTS both with python 2 and python, it is really a hectic process for beginners, for caffe with python 2.7 make sure that your /.local/lib/python2.7/site-packages only contains a version same as you protoc version. protoc version can be checked by entering
protoc --version
for me i got problems with python 2.7 because by mistake i installed protbuf 3.0 alpha in python 2.7 site packages, so there was a protobuf error after removing it from python 2.7 site packages everything worked fine
also install python-dev version
apt-get install the python3.x-dev
and for python 3.5 make sure you have python 3.0 alpha, if you have both python 2.7 and python 3.x in the system use pip3 otherwise use pip

pip3 install protobuf==3.0.0-alpha-3

or another protobuf such as 3.5 version of protobuf.
also do this
pip3 install python-dateutil --upgrade
after that do
make clean
make all
make runtest
make pycaffe
after performing make all make runtest steps don't forget to do that
sudo ldconfig

hope everything works OK for you.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants