首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >输入错误:_pywrap_tensorflow_internal.so:未定义符号: PyClass_Type

输入错误:_pywrap_tensorflow_internal.so:未定义符号: PyClass_Type
EN

Stack Overflow用户
提问于 2018-03-23 09:15:45
回答 1查看 2.4K关注 0票数 4

我想做流的准确性,并遵循Tensorflow音频识别官方网页上的说明。我的环境是virtualenv中的Ubuntu16.04、Python3.5、tensorflow 16.0。

在虚拟环境中运行此命令之后,

代码语言:javascript
复制
bazel run tensorflow/examples/speech_commands:generate_streaming_test_wav

出现了一些错误信息。有关更多细节,请查看这个要旨

总之,

第1~7行:我想确保导入tensorflow是可以的

第9~69行:错误消息显示加载本机TensorFlow运行时失败。

代码语言:javascript
复制
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。

代码语言:javascript
复制
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.

任何建议都将不胜感激。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2020-07-30 07:39:57

关于最后一个错误: ImportError:无法导入tensorflow。不要从源目录导入tensorflow;

这意味着您不能在源代码路径的根中“导入tensorflow”(比如:/tensorflow-2.2.0)。您只需找到另一条路径,然后“导入tensorflow”。

关于第一个错误,我想我遇到了一个类似的错误,我的解决方案是

  1. pip卸载tensorflow
  2. 重建丹瑟尔流
  3. 重新安装tensorflow。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49446047

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档