如何正确安装TensorFlow-“无法加载本机TensorFlow运行时”?

时间:2018-12-03 14:43:50

标签: python tensorflow install

我已经有几年没有使用python了,但是我对在TensorFlow上获得一些有趣的经验感兴趣。

我在获取tensorflow正确下载时遇到了一些问题!我按照tensorflow网站的指示使用pip进行安装,并收到以下消息:

Brandens-MacBook-Pro-2:~ branden$ pip3 install --user --upgrade tensorflow  # install in $HOME
Requirement already up-to-date: tensorflow in ./.local/lib/python3.6/site-packages (1.12.0)
Requirement already satisfied, skipping upgrade: wheel>=0.26 in ./anaconda3/lib/python3.6/site-packages (from tensorflow) (0.32.3)
Requirement already satisfied, skipping upgrade: numpy>=1.13.3 in ./.local/lib/python3.6/site-packages (from tensorflow) (1.15.4)
Requirement already satisfied, skipping upgrade: keras-preprocessing>=1.0.5 in ./.local/lib/python3.6/site-packages (from tensorflow) (1.0.5)
Requirement already satisfied, skipping upgrade: astor>=0.6.0 in ./.local/lib/python3.6/site-packages (from tensorflow) (0.7.1)
Requirement already satisfied, skipping upgrade: absl-py>=0.1.6 in ./.local/lib/python3.6/site-packages (from tensorflow) (0.6.1)
Requirement already satisfied, skipping upgrade: gast>=0.2.0 in ./.local/lib/python3.6/site-packages (from tensorflow) (0.2.0)
Requirement already satisfied, skipping upgrade: protobuf>=3.6.1 in ./.local/lib/python3.6/site-packages (from tensorflow) (3.6.1)
Requirement already satisfied, skipping upgrade: termcolor>=1.1.0 in ./.local/lib/python3.6/site-packages (from tensorflow) (1.1.0)
Requirement already satisfied, skipping upgrade: six>=1.10.0 in ./anaconda3/lib/python3.6/site-packages (from tensorflow) (1.11.0)
Requirement already satisfied, skipping upgrade: keras-applications>=1.0.6 in ./.local/lib/python3.6/site-packages (from tensorflow) (1.0.6)
Requirement already satisfied, skipping upgrade: tensorboard<1.13.0,>=1.12.0 in ./.local/lib/python3.6/site-packages (from tensorflow) (1.12.0)
Requirement already satisfied, skipping upgrade: grpcio>=1.8.6 in ./.local/lib/python3.6/site-packages (from tensorflow) (1.16.1)
Requirement already satisfied, skipping upgrade: setuptools in ./anaconda3/lib/python3.6/site-packages (from protobuf>=3.6.1->tensorflow) (40.6.2)
Requirement already satisfied, skipping upgrade: h5py in ./.local/lib/python3.6/site-packages (from keras-applications>=1.0.6->tensorflow) (2.8.0)
Requirement already satisfied, skipping upgrade: werkzeug>=0.11.10 in ./anaconda3/lib/python3.6/site-packages (from tensorboard<1.13.0,>=1.12.0->tensorflow) (0.14.1)
Requirement already satisfied, skipping upgrade: markdown>=2.6.8 in ./.local/lib/python3.6/site-packages (from tensorboard<1.13.0,>=1.12.0->tensorflow) (3.0.1)
Brandens-MacBook-Pro-2:~ branden$ 

但是,当我尝试将相关的tensorflow文件导入脚本时,出现错误(在下面发布),由于我很擅长编码,但在外部没有太多经验,所以我不确定如何解决问题基本知识。

    Brandens-MacBook-Pro-2:~ branden$ python
Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:07:29) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "/Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/Users/branden/.local/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/branden/anaconda3/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/Users/branden/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: dlopen(/Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _clock_gettime
  Referenced from: /Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.so (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib
 in /Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.so

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/branden/.local/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/Users/branden/.local/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/branden/anaconda3/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/Users/branden/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: dlopen(/Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _clock_gettime
  Referenced from: /Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.so (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib
 in /Users/branden/.local/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.so


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

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

有人知道如何解决此问题吗?

1 个答案:

答案 0 :(得分:0)

尝试这些步骤以使用Conda进行安装

  1. 安装Anaconda或Miniconda。
  2. 使用python 3.6版创建新的conda环境
  3. 使用conda install tensorflow=1.10.0安装TensorFlow。