tensorflow python3.5_python 3.5.2的Tensorflow SyntaxError

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 "", line 1, in

File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in

from tensorflow.python import *

File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 54, in

from tensorflow.core.framework.graph_pb2 import *

File "/usr/local/lib/python3.5/dist-packages/tensorflow/core/framework/graph_pb2.py", line 6, in

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?

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当使用Python 3.5.2版本时,如果出现"SyntaxError: invalid syntax"的错误,这可能是由于使用了不兼容的语法或语言特性所导致的。引用和引用中提到的错误信息与升级pip并使用新版本导致的问题有关。 具体地说,在Python 3.5.2版本中,使用类似于f字符串(f-string)的语法可能会导致"SyntaxError: invalid syntax"错误。这是因为该语法在Python 3.6及更高版本中引入,而在Python 3.5.2中不受支持。 解决此问题的一种方法是降级pip或重新安装适用于Python 3.5.2版本的pip。引用中指出,Python 3.5.2版本在2020年9月13日停止维护,而pip 21.0在2021年1月将停止对Python 3.5的支持。因此,为了避免与版本不兼容的问题,建议降级pip并重新安装适用于Python 3.5.2版本的pip。 总结一下,当出现"python 3.5.2 SyntaxError: invalid syntax"错误时,这可能是因为使用了不兼容的语法或版本不匹配所导致的。为了解决这个问题,您可以尝试降级pip或重新安装适用于Python 3.5.2版本的pip。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [SyntaxError: invalid syntax](https://blog.csdn.net/weixin_44075361/article/details/124667805)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值