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?
Is this the full stack trace? What is the error message of the exception?
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
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?
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'
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.
Yes there is a lot of syntax errors, if you don't want to handle yourself use python2
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.
Most helpful comment
That last stable release (2.6.1) doesn't support python3. For python3, you need to install the latest beta versions:
Since it's beta, it's not automatically picked up by "pip3 instal protobuf" and you need to set the version number explicitly.