首页 > 解决方案 > 收到错误:tensorflow 的语法无效

问题描述

在不同环境的 conda 中安装 tensorflow。

导入 tensorflow 时仍然出错。

Traceback (most recent call last):

  File "C:\Users\HP\Anaconda3\envs\tensorflow_cpu\lib\site-packages\IPython\core\interactiveshell.py", line 3331, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-1-64156d691fe5>", line 1, in <module>
    import tensorflow as tf

  File "C:\Users\HP\Anaconda3\envs\tensorflow_cpu\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import

  File "C:\Users\HP\Anaconda3\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow

  File "C:\Users\HP\Anaconda3\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *

  File "C:\Users\HP\Anaconda3\envs\tensorflow_cpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 111
    def TFE_ContextOptionsSetAsync(arg1, async):
                                         ^
SyntaxError: invalid syntax

请帮我怎么办我也改变了python的路径仍然存在问题。

标签: pythontensorflow

解决方案


推荐阅读