我正在尝试使用Keras,但它向mw显示了此错误:(。
Using TensorFlow backend.
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import keras
File "C:\Python37\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Python37\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\Python37\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\Python37\lib\site-packages\keras\backend\__init__.py", line 89, in <module>
from .tensorflow_backend import *
File "C:\Python37\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "C:\Python37\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Python37\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 114
def TFE_ContextOptionsSetAsync(arg1, async):
^
SyntaxError: invalid syntax
python版本:3.7。 Tensorflow版本:1.10.0。
答案 0 :(得分:0)
在Github上共享的问题是async
是python 3.7中的保留关键字。
您可以通过访问文件(在您的情况下为C:\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py
)并将async
的所有外观更改为类似async1
的方式来解决此问题。
async
变量位于114
,115
,150
和151
行中。