Tensorflow SyntaxError with python 3.5.2

2019-07-25 04:03发布

问题:

I'm trying to install tensorflow to my Linux systems (Linuxmint) with Python 3.5 using pip installation with CPU support. After the installation is done; to validate my installation I try to run the following script

python3

>import tensorflow as tf 

the result is the following:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module> from tensorflow.python import * File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 54, in <module> from tensorflow.core.framework.graph_pb2 import * File "/usr/local/lib/python3.5/dist-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module> from google.protobuf import descriptor as _descriptor File "/usr/local/lib/python3.5/dist-packages/pygoogle/google.py", line 118 %(__credits__)s""" % globals() ^ SyntaxError: invalid syntax

Can someone please help on the topic?

回答1:

After upgrading tensorflow 1.3.0 to 1.4.0 I encountered this error. to solve it, I check different steps :

sudo pip3 uninstall tensorflow-gpu
sudo pip3 uninstall protobuf
sudo pip3 install tensorflow-gpu==1.3.0
sudo pip3 install protobuf==3.3.0

but the error was not resolved. finally, I uninstalled pygoogle

sudo pip3 uninstall pygoogle

and it works! Hope it will work for you too.