Tensorflow:导入失败,"无法加载本机TensorFlow运行时。"

时间:2017-05-31 15:47:07

标签: python tensorflow pip

我试图在Mac OS 10.6.8(现在我已经得到)的virtualenv中使用Python 3.6安装了版本的tensorflow的CPU版本,使用所描述的包url {{3} }。它似乎工作正常:

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.

不幸的是,现在here中提到了这一点。谁能告诉我这里出了什么问题?

1 个答案:

答案 0 :(得分:1)

  

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

libc ++未包含在MacOS 10.6中,因为Apple还没有切换到Clang和libc ++。那是你的问题。

请参阅this