4

我浏览了https://github.com/tensorflow/models/tree/master/syntaxnet并做了它所说的一切。

我跑了这个来测试:

bazel test --linkopt=-headerpad_max_install_names \
    syntaxnet/... util/utf8/...

我只能使 6 次测试通过,6 次失败。

但是当我运行演示时,我得到了错误。

User:syntaxnet hk$ echo "Parsey McParseface is my favorite parser" | syntaxnet/demo.sh

Traceback (most recent call last):
  File "/git/models/syntaxnet/bazel-bin/syntaxnet/conll2tree.runfiles/syntaxnet/conll2tree.py", line 20, in <module>
    import tensorflow as tf
  File "/git/models/syntaxnet/bazel-bin/syntaxnet/conll2tree.runfiles/external/tf/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/git/models/syntaxnet/bazel-bin/syntaxnet/conll2tree.runfiles/external/tf/tensorflow/python/__init__.py", line 45, in <module>
    from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
Traceback (most recent call last):
Traceback (most recent call last):
  File "/git/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/syntaxnet/parser_eval.py", line 23, in <module>
  File "/git/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/syntaxnet/parser_eval.py", line 23, in <module>
    import tensorflow as tf
  File "/git/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/__init__.py", line 23, in <module>
    import tensorflow as tf
  File "/git/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/git/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/python/__init__.py", line 45, in <module>
    from tensorflow.python import *
  File "/git/models/syntaxnet/bazel-bin/syntaxnet/parser_eval.runfiles/external/tf/tensorflow/python/__init__.py", line 45, in <module>
    from tensorflow.python import pywrap_tensorflow
ImportError:     from tensorflow.python import pywrap_tensorflow
cannot import name pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow

这是怎么回事?demo.sh 是否在与其放置位置不同的位置寻找那些 python 导入?

4

2 回答 2

3

解决了。我错过了 bazel 安装中的一些步骤,特别是“完成 bash”。我以为那只适用于jdk7。

于 2016-05-21T17:21:39.597 回答
2

尝试使用 bazel 命令再次构建和测试 SyntaxNet。我遇到了一个与此非常相似的错误,即 bazel 在我的机器上找不到 python 目录。在多次尝试定位 python 目录后,bazel 完成了 SyntaxNet 的构建和测试,其中 1 次失败测试(根据 bazel 是 localhost 错误),demo.sh 工作正常。

我再次尝试构建和测试 Syntaxnet,幸好这次它通过了 12 次测试。

INFO: Elapsed time: 88.935s, Critical Path: 31.63s
//syntaxnet:arc_standard_transitions_test                       (cached) PASSED in 3.5s
//syntaxnet:beam_reader_ops_test                                (cached) PASSED in 20.6s
//syntaxnet:graph_builder_test                                  (cached) PASSED in 21.4s
//syntaxnet:lexicon_builder_test                                (cached) PASSED in 8.7s
//syntaxnet:parser_features_test                                (cached) PASSED in 0.7s
//syntaxnet:parser_trainer_test                                 (cached) PASSED in 36.4s
//syntaxnet:reader_ops_test                                     (cached) PASSED in 6.0s
//syntaxnet:sentence_features_test                              (cached) PASSED in 1.6s
//syntaxnet:tagger_transitions_test                             (cached) PASSED in 1.6s
//syntaxnet:text_formats_test                                   (cached) PASSED in 8.7s
//util/utf8:unicodetext_unittest                                (cached) PASSED in 5.6s
//syntaxnet:shared_store_test                                            PASSED in 6.0s

Executed 1 out of 12 tests: 12 tests pass.

还有来自 bazel 的额外提醒可能会有所帮助:

There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.

希望这可以帮助。

于 2016-05-18T09:03:47.437 回答