【问题标题】:Tensorflow translate.py import error: No module named translateTensorflow translate.py 导入错误:没有名为 translate 的模块
【发布时间】:2015-11-25 07:21:51
【问题描述】:

我正在尝试从 python 控制台而不是通过 bazel -build 运行 Tensorflow 的 translate.py,但在这两行中出现错误:

from tensorflow.models.rnn.translate import data_utils
from tensorflow.models.rnn.translate import seq2seq_model

ImportError: No module named translate

我检查了文件夹,发现“init.py”文件在那里,但python似乎认为没有翻译这样的模块。 我该如何解决这个问题?

【问题讨论】:

    标签: python tensorflow


    【解决方案1】:

    最好的方法是导航到包含翻译模块的文件夹并运行它。您还可以将翻译模块下载到任何其他地方并运行它。但是,不要忘记将上面的行更改为:

    from translate import data_utils
    from translate import seq2seq_model
    

    【讨论】:

      【解决方案2】:

      我通过删除所有from tensorflow.models.rnn.translate 语句解决了这个问题,只留下了

      import data_utils
      import seq2seq_model
      

      translate.py

      import data_utils
      

      seq2seq_model.py.

      【讨论】:

        猜你喜欢
        • 2018-03-16
        • 1970-01-01
        • 2018-07-07
        • 2020-08-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-07-10
        相关资源
        最近更新 更多