When Python 2 installs tensorflow, test after the installation is completed:
import tensorflow as tf
Will report an error:
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
File “/home/zhaokai/.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/zhaokai/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py”, line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File “/home/zhaokai/.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/zhaokai/.local/lib/python2.7/site-packages/google/protobuf/descriptor.py”, line 113
class DescriptorBase(metaclass=DescriptorMetaclass):
^
SyntaxError: invalid syntax
The solution is to re-install protobuf:
pip install protobuf==3.17.3
then Import tensorflow again.
Read More:
- [Solved] SyntaxError: Invalid regular expression: invalid group specifier name
- PHP Parse error: syntax error, unexpected ‘class‘ (T_CLASS), expecting identifier (T_STRING)
- [Solved] Tensorflow-gpu 2.0.0 Run Error: ModuleNotFoundError: No module named ‘tensorflow_core.estimator‘
- Tensorflow error: attributeerror: module ‘tensorflow_ API. V1. Train ‘has no attribute’ summarywriter ‘
- TensorFlow error: AttributeError: module ‘tensorflow_core._api.v2.train’ has no attribute ‘Optimizer‘
- [Solved] Tensorflow Error: Failed to load the native TensorFlow runtime.
- Error:invalid new-expression of abstract class type XXX [How to Solve]
- Firefox: How to Solve Syntax error: invalid regexp group
- [Solved] Notwritablepropertyexception: invalid property ‘mapperhelper’ of bean class
- [Solved] Unreal Engine Error: Widget Blueprint could not be loaded because it derives from an invalid class
- [Solved] Tensorflow/Keras Error reading weights: ValueError: axes don‘t match array
- Error:scalac: missing or invalid dependency detected while loading class file ***
- [Solved] Pip install icu failed: Command “python setup.py egg_info” failed with error code 1 in
- Centos pip install uwsgi error: “fatal error: Python.h: No such file or directory”
- [Solved] A needed class was not found. This could be due to an error in your runpath. Missing class: scala/co
- [ubuntu14.04]Tensorflow: Could not find any downloads that satisfy the requirement
- [Solved] SyntaxError: Missing parentheses in call to ‘print‘. Did you mean print(e)?
- Uncaught SyntaxError: Cannot use import statement outside a module
- [Solved] Tensorflow Error: failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
- [Solved] Tensorflow Win10: ImportError: DLL load failed