簡體   English   中英

張量流導入錯誤:_pywrap_tensorflow_internal.so:未定義符號:PyClass_Type

[英]tensorflow import error: _pywrap_tensorflow_internal.so: undefined symbol: PyClass_Type

我想做Streaming Accuracy並按照Tensorflow Audio識別官方網頁上的說明進行操作 我的環境是 virtualenv 中的 Ubuntu 16.04、Python 3.5、tensorflow 16.0。

在 virtualenv 環境中運行此命令后,

bazel run tensorflow/examples/speech_commands:generate_streaming_test_wav

一些錯誤信息出來了。 請檢查此要點以獲取更多詳細信息。

簡而言之,

第 1~7 行:我想確保導入 tensorflow 沒問題

第 9~69 行:錯誤消息顯示 Failed to load the native TensorFlow runtime。

INFO: Running command line: bazel-bin/tensorflow/examples/speech_commands/generate_streaming_test_wav
Traceback (most recent call last):
  File "/home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/home/jean_lin/py35_tf16/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/home/jean_lin/py35_tf16/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: /home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyClass_Type

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/examples/speech_commands/generate_streaming_test_wav.py", line 47, in <module>
    import tensorflow as tf
  File "/home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *  # pylint: disable=redefined-builtin
  File "/home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/home/jean_lin/py35_tf16/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/home/jean_lin/py35_tf16/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: /home/jean_lin/.cache/bazel/_bazel_jean_lin/7ec2afa2cc3b112c8391a9677667186f/execroot/org_tensorflow/bazel-out/k8-opt/bin/tensorflow/examples/speech_commands/generate_streaming_test_wav.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyClass_Type


Failed to load the native TensorFlow runtime.

第 72~93 行:我不知道為什么它無法加載原生 tensorflow。 我嘗試再次導入 tensorflow。 並發現我無法正確導入 tensorflow。

Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
  File "/home/jean_lin/kws/tensorflow/tensorflow/python/platform/self_check.py", line 25, in <module>
    from tensorflow.python.platform import build_info
ImportError: cannot import name 'build_info'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jean_lin/kws/tensorflow/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *  # pylint: disable=redefined-builtin
  File "/home/jean_lin/kws/tensorflow/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/jean_lin/kws/tensorflow/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
    from tensorflow.python.platform import self_check
  File "/home/jean_lin/kws/tensorflow/tensorflow/python/platform/self_check.py", line 27, in <module>
    raise ImportError("Could not import tensorflow. Do not import tensorflow "
ImportError: Could not import tensorflow. Do not import tensorflow from its source directory; change directoryto outside the TensorFlow source tree, and relaunch your Python interpreter from there.

任何建議將不勝感激。 謝謝。

關於最后一個錯誤:ImportError:無法導入張量流。 不要從其源目錄導入 tensorflow;

這意味着您不能在源代碼路徑的根目錄中“導入 tensorflow”(例如:/tensorflow-2.2.0)。 您只需找到另一條路徑,然后“導入 tensorflow”。

關於第一個錯誤,我想我遇到了一個類似的錯誤,我的解決方案是

  1. pip卸載張量流
  2. 重建張量流
  3. 重新安裝 tensorflow。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM