2017-05-31 39 views
0

我试图在Python操作系统10.6.8(我现在所有的版本)上用virtualenv在python 3.6上安装tensorflow的CPU版本,使用包装url,如here所述。这似乎很好地工作:Tensorflow:导入失败,显示“无法加载本地TensorFlow运行时”。

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. 

不幸的是,现在common installation problems中提到了这一点。有人可以告诉我这里有什么问题吗?

回答

1

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++未包含在MacOS 10.6中,因为Apple尚未切换到Clang和libC++。那是你的问题。

请参阅this

+0

谢谢,但因为我不能冒险搞乱我的系统似乎我现在不能使用TF :( – user8793

+0

如果可能的话,你仍然可以用CPU运行:) – frankyjuang

+0

你是什么意思,我认为是CPU版本? – user8793

相关问题