Tensorflow `Syntax Error: pywrap_tensorflow` After Install

蓝咒 提交于 2021-02-04 08:29:05

问题


I've setup a virtualenv and using pip installed tensorflow via sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0-py3-none-any.whl.

However, when I open a python shell to test the install I get the following error:

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/joshuablew/Projects/Environments/proj1/lib/python3.7/site-packages/tensorflow/__init__.py", line 22, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/Users/joshuablew/Projects/Environments/proj1/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/joshuablew/Projects/Environments/proj1/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/Users/joshuablew/Projects/Environments/proj1/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 114
    def TFE_ContextOptionsSetAsync(arg1, async):
                                             ^
SyntaxError: invalid syntax

I've searched around but can't find a straightforward solution to this. Any ideas? Thanks!


回答1:


async is a reserved keyword in Python 3 (here's the full list).

Look like you aren't the only one running into this problem, there's an active thread on the tensorflow github issue tracker addressing it that dates back to July: https://github.com/tensorflow/tensorflow/issues/20517



来源:https://stackoverflow.com/questions/51996163/tensorflow-syntax-error-pywrap-tensorflow-after-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!