简体   繁体   English

Tensorflow translate.py导入错误:没有名为translate的模块

[英]Tensorflow translate.py import error: No module named translate

I'm trying to run Tensorflow's translate.py from a python console rather than through bazel -build, but I get an error at these two lines: 我试图从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

I've checked the folder to see that the " init .py" file is there, but python seems to think there is no such module as translate. 我已经检查了文件夹,看到“ init .py”文件在那里,但是python似乎认为没有像translate这样的模块。 How can i fix this? 我怎样才能解决这个问题?

The best way to do this is to navigate to folder containing the translate module and running it. 执行此操作的最佳方法是导航到包含翻译模块并运行它的文件夹。 You can also download the translate module to any other place and run it. 您也可以将翻译模块下载到任何其他地方并运行它。 However, don't forget to change the above lines to: 但是,不要忘记将以上行更改为:

from translate import data_utils
from translate import seq2seq_model

I resolved this issue by removing all the from tensorflow.models.rnn.translate statements, leaving just 我通过删除所有from tensorflow.models.rnn.translate语句解决了这个问题

import data_utils
import seq2seq_model

in translate.py and translate.py

import data_utils

in seq2seq_model.py . seq2seq_model.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TensorFlow translate.py教程具有 - TensorFlow translate.py tutorial has import argostranslate.translate 说“没有名为 lzma 的模块” - import argostranslate.translate says "no module named lzma" Tensorflow 导入错误:没有名为“tensorflow”的模块 - Tensorflow import error: No module named 'tensorflow' pygame导入错误:没有名为py的模块 - Pygame Import error:No module named py ModuleNotFoundError:即使在“pip install translate”之后,也没有名为“translate”的模块 - ModuleNotFoundError: No module named 'translate' , even after "pip install translate" 在 Mac 上运行“import tensorflow”会产生“No module named tensorflow”错误 - Running “import tensorflow” on Mac generates "No module named tensorflow" error TensorFlow导入错误:没有名为_pywrap_tensorflow的模块 - TensorFlow import error: no module named _pywrap_tensorflow tensorflow 导入错误:没有名为 tensorflow.python.checkpoint 的模块 - tensorflow import error: No module named tensorflow.python.checkpoint Python:'import node.py'引发“没有名为py的模块”错误 - Python: 'import node.py' raises “No module named py”-error 谷歌翻译器 django moduleNotFoundError:没有名为“translate”的模块 - google translator django moduleNotFoundError: No module named 'translate'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM