繁体   English   中英

Tensorflow:导入失败,并显示“无法加载本机TensorFlow运行时。”

[英]Tensorflow: Import failed with “Failed to load the native TensorFlow runtime.”

我正在尝试使用Python 3.6在Mac OS 10.6.8(我现在已经拥有)上的virtualenv中安装tensorflow的CPU版本,使用此处所述的包url。 似乎工作正常:

Ms-MacBook:tensorflow User$ source tfvenv/bin/activate
(tfvenv) Ms-MacBook:tensorflow User$ python --version
Python 3.6.1
(tfvenv) Ms-MacBook:tensorflow User$ pip --version
pip 9.0.1 from /Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages (python 3.6)
(tfvenv) Ms-MacBook:tensorflow User$ pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.1.0-py3-none-any.whl
[...]
Successfully installed numpy-1.12.1 protobuf-3.3.0 tensorflow-1.1.0 werkzeug-0.12.2

但是,当我尝试在Python解释器中导入tensorflow时,出现此错误:

(tfvenv) Ms-MacBook:tensorflow User$ python
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: dlopen(/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: /usr/lib/libc++.1.dylib
  Referenced from: /Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
  Reason: image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
  File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: dlopen(/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: /usr/lib/libc++.1.dylib
  Referenced from: /Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
  Reason: image not found


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

不幸的是,现在在常见的安装问题中提到了这一点。 谁能告诉我这是怎么回事?

ImportError:dlopen(/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so,10):库未加载:/usr/lib/libc++.1.dylib

MacOS 10.6中未包含libc ++,因为苹果尚未切换到Clang和libc ++。 那是你的问题。

参考这个

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM