问题1: class DescriptorBase(metaclass=DescriptorMetaclass): ^Syntax invalid syntax

virtual@virtual-machine:~$ python -c 'import keras; print(keras.__version__)'
Using TensorFlow backend.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/song/.local/lib/python2.7/site-packages/keras/__init__.py", line 3, in <module>
    from . import utils
  File "/home/song/.local/lib/python2.7/site-packages/keras/utils/__init__.py", line 6, in <module>
    from . import conv_utils
  File "/home/song/.local/lib/python2.7/site-packages/keras/utils/conv_utils.py", line 9, in <module>
    from .. import backend as K
  File "/home/song/.local/lib/python2.7/site-packages/keras/backend/__init__.py", line 1, in <module>
    from .load_backend import epsilon
  File "/home/song/.local/lib/python2.7/site-packages/keras/backend/load_backend.py", line 90, in <module>
    from .tensorflow_backend import *
  File "/home/song/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
    import tensorflow as tf
  File "/home/song/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/home/song/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/home/song/.local/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 7, in <module>
    from google.protobuf import descriptor as _descriptor
  File "/home/song/.local/lib/python2.7/site-packages/google/protobuf/descriptor.py", line 113
    class DescriptorBase(metaclass=DescriptorMetaclass):
                                  ^
SyntaxError: invalid syntax

Issue:In order to test the installed the keras and tensorflow, syntaxError

Reason:  Protobuf version is not correct. according to the default instructio, i installed the relevant packages and dependencies. the protobuf version is 3.18.0. However, accoding to the packages installed such as Python, Tensorflow, Keras. these packages need the protobuf==3.17.3. Thus, we can find the SyntaxError hints.

Answer: Firstly, we need to remove the protobuf ==3.18.0. the code is such as:

pip uninstall protobuf==3.18.0

 Then, we can install the correct protobuf version.

pip install protobuf==3.17.3

Note: if you are not sure what's the correct versions, you can use the order to check the package ,installed by youself, and find the correct version of denpendcy. 

  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值