首页 > 解决方案 > Python3.7与Tensorflow不兼容?

问题描述

我正在尝试继续使用自 9 月以来我没有使用过的 Rasa 聊天机器人,但我发现 Tensorflow 的依赖存在语法问题。我不知道这是因为我的依赖项需要更新,还是因为我按照 GitHub 上的人的建议使用了 python3.7,或者其他一些原因。

(moo_env) C:\Users\antoi\Documents\Programming\projects\moodbot>py train_online.py
Traceback (most recent call last):
  File "train_online.py", line 37, in <module>
    nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/moodnlu')
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_core\interpreter.py", line 221, in __init__
    self._load_interpreter()
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_core\interpreter.py", line 237, in _load_interpreter
    self.interpreter = Interpreter.load(self.model_directory)
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_nlu\model.py", line 276, in load
    skip_validation)
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_nlu\model.py", line 298, in create
    components.validate_requirements(model_metadata.component_classes)
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_nlu\components.py", line 49, in validate_requirements
    from rasa_nlu import registry
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_nlu\registry.py", line 23, in <module>
    from rasa_nlu.classifiers.embedding_intent_classifier import \
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\rasa_nlu\classifiers\embedding_intent_classifier.py", line 32, in <module>
    import tensorflow as tf
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\antoi\Documents\Programming\projects\moodbot\moo_env\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 114
    def TFE_ContextOptionsSetAsync(arg1, async):

SyntaxError: invalid syntax

您可以在Github 存储库中找到我的代码

标签: python-3.xtensorflowrasa-nlurasa-core

解决方案


原因是这一行pywrap_tensorflow_internal.py

def TFE_ContextOptionsSetAsync(arg1, async):

从 Python 3.5 开始,async(and await) 是关键字,不能再用作标识符。我假设您使用的是非常过时的 tensorflow 版本。


推荐阅读