python protobuf error class DescriptorBase(metaclass=DescriptorMetaclass) SyntaxError: invalid syntax
Error
File "/root/xxx/xxx/xxx/xxx.py", line 6, in <module> from google.protobuf import descriptor as _descriptor File "/usr/lib/python2.7/site-packages/google/protobuf/descriptor.py", line 117 class DescriptorBase(metaclass=DescriptorMetaclass): ^ SyntaxError: invalid syntax
https://github.com/protocolbuffers/protobuf/issues/9045
解决
pip install protobuf==3.17.3
log
# pip install protobuf==3.17.3 Collecting protobuf==3.17.3 Downloading https://files.pythonhosted.org/packages/d5/e0/20ba06eb42155cdb4c741e5caf9946e4569e26d71165abaecada18c58603/protobuf-3.17.3-py2.py3-none-any.whl (173kB) 100% |################################| 174kB 1.2MB/s Collecting six>=1.9 (from protobuf==3.17.3) Downloading https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl Installing collected packages: six, protobuf Found existing installation: protobuf 4.21.1 Uninstalling protobuf-4.21.1: Successfully uninstalled protobuf-4.21.1 Successfully installed protobuf-3.17.3 six-1.16.0
Copyright © 2024 Primzahl. All rights reserved.