简体   繁体   中英

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

I'm trying to install the CPU version of tensorflow in a virtualenv on Mac OS 10.6.8 (all I've got for now) with Python 3.6, using the package url as described here . It seems to work fine:

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

However, when I try to import tensorflow in a Python interpreter I get this error:

(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.

Unfortunately there is now mention of this among the common installation problems . Can anybody tell me what's going wrong here?

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

libc++ was not included in MacOS 10.6 because Apple had not switched to Clang and libc++ yet. That's your problem.

Refer to this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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