问题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 "", line 1, in 
  File "/home/song/.local/lib/python2.7/site-packages/keras/__init__.py", line 3, in 
    from . import utils
  File "/home/song/.local/lib/python2.7/site-packages/keras/utils/__init__.py", line 6, in 
    from . import conv_utils
  File "/home/song/.local/lib/python2.7/site-packages/keras/utils/conv_utils.py", line 9, in 
    from .. import backend as K
  File "/home/song/.local/lib/python2.7/site-packages/keras/backend/__init__.py", line 1, in 
    from .load_backend import epsilon
  File "/home/song/.local/lib/python2.7/site-packages/keras/backend/load_backend.py", line 90, in 
    from .tensorflow_backend import *
  File "/home/song/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 5, in 
    import tensorflow as tf
  File "/home/song/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 28, in 
    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 
    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 
    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

Issure: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. 

你可能感兴趣的:(linux问题,linux)