keras -SyntaxError:语法无效

时间:2019-08-29 06:52:07

标签: python keras syntax-error

如何解决错误?`

from keras.models import Sequential
from keras.layers import Flatten, Dense, Embedding
from keras.preprocessing.text import Tokenizer
....

错误:

Using TensorFlow backend.
Traceback (most recent call last):
File "C:\Users\Desktop\a.py", line 3, in <module>
from keras.models import Sequential
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site- 
packages\keras-2.2.4-py3.7.egg\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site- 
packages\keras-2.2.4-py3.7.egg\keras\utils\__init__.py", line 6, in 
<module>
from . import conv_utils
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site- 
packages\keras-2.2.4-py3.7.egg\keras\utils\conv_utils.py", line 9, in 
<module>
from .. import backend as K
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site- 
packages\keras-2.2.4-py3.7.egg\keras\backend\__init__.py", line 89, in 
<module>
from .tensorflow_backend import *
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site- 
packages\keras-2.2.4-py3.7.egg\keras\backend\tensorflow_backend.py", 
line 5, in <module>
import tensorflow as tf
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site- 
packages\tensorflow-1.8.0-py3.7.egg\tensorflow\__init__.py", line 24, in 
<module>
from tensorflow.python import pywrap_tensorflow  # pylint: 
disable=unused-import
File "C:\UsersAppData\Local\Programs\Python\Python37-32\lib\site- 
packages\tensorflow-1.8.0-py3.7.egg\tensorflow\python\__init__.py", line 
49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site- 
packages\tensorflow-1.8.0- 
py3.7.egg\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\AppData\Local\Programs\Python\Python37-32\lib\site- 
packages\tensorflow-1.8.0- 
py3.7.egg\tensorflow\python\pywrap_tensorflow_internal.py", line 114
def TFE_ContextOptionsSetAsync(arg1, async):
SyntaxError: invalid syntax

(我使用Windows 7)

1 个答案:

答案 0 :(得分:0)

该版本的TensorFlow不支持python 3.7,后来又添加了此支持,因此您应将TensorFlow更新为最新版本(例如1.14)。