错误:无法加载本机TensorFlow运行时

时间:2017-06-19 05:58:24

标签: python python-3.x tensorflow

我是tensorflow的新手,今天我使用:

安装了tensorflow
C:\>pip3 install --upgrade tensorflow
Collecting tensorflow
  Using cached tensorflow-1.2.0-cp35-cp35m-win_amd64.whl
Requirement already up-to-date: bleach==1.5.0 in c:\python35\lib\site-packages (
from tensorflow)
Requirement already up-to-date: werkzeug>=0.11.10 in c:\python35\lib\site-packag
es (from tensorflow)
Requirement already up-to-date: html5lib==0.9999999 in c:\python35\lib\site-pack
ages (from tensorflow)
Requirement already up-to-date: protobuf>=3.2.0 in c:\python35\lib\site-packages
 (from tensorflow)
Requirement already up-to-date: backports.weakref==1.0rc1 in c:\python35\lib\sit
e-packages (from tensorflow)
Requirement already up-to-date: markdown==2.2.0 in c:\python35\lib\site-packages
 (from tensorflow)
Requirement already up-to-date: numpy>=1.11.0 in c:\python35\lib\site-packages (
from tensorflow)
Requirement already up-to-date: six>=1.10.0 in c:\python35\lib\site-packages (fr
om tensorflow)
Requirement already up-to-date: wheel>=0.26 in c:\python35\lib\site-packages (fr
om tensorflow)
Requirement already up-to-date: setuptools in c:\python35\lib\site-packages (fro
m protobuf>=3.2.0->tensorflow)
Installing collected packages: tensorflow
Successfully installed tensorflow-1.2.0

当我尝试导入tensorflow时,它会抛出:

C:\>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 906, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <modu
le>
    from tensorflow.python import *
  File "C:\Python35\lib\site-packages\tensorflow\python\__init__.py", line 49, i
n <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 906, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems

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

我正在使用python 3.5.2 64bit,我真的不知道为什么导入过程会抛出错误,请帮助我大师

谢谢,最好的问候

14 个答案:

答案 0 :(得分:5)

先卸载此

pip uninstall tensorflow

现在可以重新安装下载此tensorflow wheel文件

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

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

答案 1 :(得分:3)

我遇到了类似的问题。我使用的是Windows 8.1 (64 bit)操作系统和Python 3.6.2 (64 bit)

我已通过vc_redist.x64.exe安装Visual C++ Redistributable for Visual Studio 2015 (vc_redist.x64.exe)来解决问题。

答案 2 :(得分:3)

我遵循这行代码 pip install tensorflow --upgrade --force-reinstall

答案 3 :(得分:3)

这是一个解决方案:

如果您希望具有最低依赖性的 Tensorflow版本2 ,请使用以下版本:

pip install tensorflow==2.0.0b1

答案 4 :(得分:3)

您可以尝试将TensorFlow降级或使用TensorFlow最新版本

pip install tensorflow

答案 5 :(得分:1)

当我在python 3.6上通过pip安装tensorflow时,我在OSX Siera上遇到了类似的错误。它通过使用标识TensorFlow Python包的binary URL来修复

sudo pip3 install --upgrade tfBinaryURL   # Python 3.n

在我的情况下tfBinaryURL如下:

sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.3.0-py3-none-any.whl

答案 6 :(得分:1)

我今天遇到了同样的问题,我在这里遵循了所有这些建议以及更多来自互联网和我自己的其他来源的建议。他们都没有工作。

我安装了tf 1.2.0并且导入它没有问题

pip3 install --upgrade tensorflow==1.2.0

此外,我发现所有版本的导入都很好,最高可达1.6.0。所以我将以1.5.0开始。 目前,最新的是1.7.0。

答案 7 :(得分:1)

您可能要安装 Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019

下载msvcp140.dll并添加到System32文件夹。

答案 8 :(得分:0)

只需下载MSVCP140.dll,解压缩然后将其粘贴到system32文件夹中。

答案 9 :(得分:0)

注意CUDA操作,因为当CUDA根本不工作时会报告这个错误。尝试从cmd,例如c:\ Program Files \ NVIDIA GPU Computing Toolkit \ CUDA \ v8.0 \ extras \ demo_suite&gt; oceanFFT.exe
如果失败,请尝试更新显卡的驱动程序(设备管理器/显示适配器/ NVIDIA ...)。

答案 10 :(得分:0)

  1. 转到[https://github.com/fo40225/tensorflow-windows-wheel][1]
  2. 基于
  3. 在python和cuda版本上复制路径之一(我用 编译器:VS2017 15.8,CUDA:否,SIMD:x86_64,这对我有用)

  4. https://github.com/fo40225/tensorflow-windows-wheel/blob/master/

  5. 之后粘贴
  6. 下载* .whl

  7. 打开anaconda并将目录更改为* .whl

  8. 的位置
  9. 运行以下命令:pip install *.whl(而不是*必须使用名称 .whl文件)

答案 11 :(得分:0)

1)我这样做了:pip uninstall tensorflow
2)从tensorflow wheel下载文件
3)然后这样做:pip install tensorflow-1.6.0-cp36-cp36m-win_amd64.whl

但是它给了我这个错误

  

错误:不支持tensorflow-1.6.0-cp36-cp36m-win_amd64.whl   在这个平台上滚动。

所以我尝试将tensorflow作为依赖项安装到已安装的 Anaconda Navigator
它为我工作!

答案 12 :(得分:0)

对于使用macOS X版本<10.12.6的mac用户,请安装tensorflow版本1.5:

pip install tensorflow==1.5

答案 13 :(得分:0)

我遇到了同样的问题,我使用的是macbook unibody(2008),它运行良好,并且我无法再对其进行更新,当前它正在运行MacOS X 10.11(ElCapitán)。因此,经过数小时的努力试图解决它,我已经能够做下一件事来解决它:

pip uninstall tensorflow

conda install tensorflow instead of "pip"

致谢!