Skip to main content
 首页 » 编程设计

python之OSX 上的 Tensorflow : Failed to load the native TensorFlow runtime (No module named pywrap_tensorflow_internal)

2025年02月15日25freeliver54

我正在尝试在我的 MacBook (OSX 10.12.5) 上安装 Tensorflow (r1.2)。 安装有效,但当我尝试在 python 中导入 TF 时出现错误。

Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
 
>>> import tensorflow as tf 
  Traceback (most recent call last): 
  File "<stdin>", line 1, in <module> 
  File "tensorflow/__init__.py", line 24, in <module> 
    from tensorflow.python import * 
  File "tensorflow/python/__init__.py", line 49, in <module> 
    from tensorflow.python import pywrap_tensorflow 
  File "tensorflow/python/pywrap_tensorflow.py", line 52, in <module> 
    raise ImportError(msg) 
  ImportError: Traceback (most recent call last): 
  File "tensorflow/python/pywrap_tensorflow.py", line 41, in <module> 
    from tensorflow.python.pywrap_tensorflow_internal import * 
  ImportError: No module named pywrap_tensorflow_internal 
 
 
Failed to load the native TensorFlow runtime. 

我在 virtualenv 中工作(使用 virtualenvwrapper)和最新的包

  • python 2.7.10
  • pip 9.0.1
  • numpy 1.13.1
  • 轮子 0.29.0
  • 6 个 1.10.0

我首先尝试使用 pip install tensorflow 安装默认的 pip 包(不支持 GPU)。 之后我还尝试在 installation tutorial 之后从源代码安装 tensorflow ,没有 CUDA 支持(配置脚本说 No CUDA support will be enabled for TensorFlow)。构建和安装报告没有错误,但我在尝试导入 tensorflow 时遇到了同样的错误。

相关问答都指出了CUDA的问题,或者Windows dll文件丢失的问题,好像不符合我的问题。

欢迎任何帮助。提前致谢。

请您参考如下方法:

我也遇到了同样的问题,我是这样做的

首先

pip uninstall tensorflow 

下载此 tensorflow wheel文件

现在使用(在同一目录中)安装它

pip install tensorflow-1.6.0-cp36-cp36m-win_amd64.whl