简体   繁体   English

张量流导入错误:_pywrap_tensorflow_internal.so:未定义符号:PyClass_Type

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

I would like to do Streaming Accuracy and follow the instructions on Tensorflow Audio recognition official webpage .我想做Streaming Accuracy并按照Tensorflow Audio识别官方网页上的说明进行操作 My environment is Ubuntu 16.04, Python 3.5, tensorflow 16.0 in virtualenv.我的环境是 virtualenv 中的 Ubuntu 16.04、Python 3.5、tensorflow 16.0。

After I ran this command in a virtualenv environment,在 virtualenv 环境中运行此命令后,

bazel run tensorflow/examples/speech_commands:generate_streaming_test_wav

some error message came out.一些错误信息出来了。 Please check this gist for more detail.请检查此要点以获取更多详细信息。

In brief,简而言之,

Line 1~7: I would like to make sure that importing tensorflow is ok第 1~7 行:我想确保导入 tensorflow 没问题

Line 9~69: The error message shows that Failed to load the native TensorFlow runtime.第 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.

Line 72~93: I have no idea why it can't load the native tensorflow.第 72~93 行:我不知道为什么它无法加载原生 tensorflow。 I try to import tensorflow again.我尝试再次导入 tensorflow。 And found out that I can't import tensorflow correctly.并发现我无法正确导入 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.

Any advise would be very appreciate.任何建议将不胜感激。 Thank you.谢谢。

About the last error: ImportError: Could not import tensorflow.关于最后一个错误:ImportError:无法导入张量流。 Do not import tensorflow from its source directory;不要从其源目录导入 tensorflow;

It means that you can't "import tensorflow" in the root of source code path(like:/tensorflow-2.2.0).这意味着您不能在源代码路径的根目录中“导入 tensorflow”(例如:/tensorflow-2.2.0)。 You just find another path then "import tensorflow".您只需找到另一条路径,然后“导入 tensorflow”。

About the first error , I think I met a similair error, my solution is关于第一个错误,我想我遇到了一个类似的错误,我的解决方案是

  1. pip uninstall tensorflow pip卸载张量流
  2. rebuild tensorflow重建张量流
  3. re-pip install tensorflow.重新安装 tensorflow。

暂无
暂无

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

相关问题 规则&#39;//tensorflow/python:_pywrap_tensorflow_internal.so&#39;的链接失败 - Linking of rule '//tensorflow/python:_pywrap_tensorflow_internal.so' failed ImportError:dlopen(...):未加载库:@rpath/_pywrap_tensorflow_internal.so - ImportError: dlopen(...): Library not loaded: @rpath/_pywrap_tensorflow_internal.so ImportError:/usr/lib/libboost_python.so.1.54.0:未定义的符号:PyClass_Type - ImportError: /usr/lib/libboost_python.so.1.54.0: undefined symbol: PyClass_Type import dlib找不到ImportError符号:_PyClass_Type - import dlib ImportError Symbol not found: _PyClass_Type 找不到dlopen符号:_PyClass_Type - dlopen Symbol not found: _PyClass_Type TensorFlow _pywrap_tensorflow_internal 错误 - TensorFlow _pywrap_tensorflow_internal Error Tensorflow '_pywrap_tensorflow_internal' 模块错误 - Tensorflow '_pywrap_tensorflow_internal' module error 使用 Mac Mojave 和 brew 安装 cgal-swig-bindings,之后找不到错误符号:_PyClass_Type - installing cgal-swig-bindings with Mac Mojave and brew, after that getting the Error Symbol not found: _PyClass_Type tensorflow安装正确,但出现错误``ImportError:在导入tensorflow为tf时没有名为&#39;_pywrap_tensorflow_internal&#39;的模块 - tensorflow installed correctly but giving error "ImportError: No module named '_pywrap_tensorflow_internal' on import tensorflow as tf 没有名为“_pywrap_tensorflow_internal”的模块错误 - No module named '_pywrap_tensorflow_internal' Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM