&引用;导入tensorflow“;在使用python 3.6.2 CPU的windows上出错

&引用;导入tensorflow“;在使用python 3.6.2 CPU的windows上出错,python,tensorflow,Python,Tensorflow,我只是想尝试tensorflow,但每当我尝试执行以下操作时,就会出现一个错误 import tensorflow as tf 错误消息是: >>> import tensorflow as tf Traceback (most recent call last): File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_imp

我只是想尝试tensorflow,但每当我尝试执行以下操作时,就会出现一个错误

import tensorflow as tf
错误消息是:

>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Python\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
ImportError: DLL load failed: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Python\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: 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:\Python\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *  # pylint: disable=redefined-builtin
  File "C:\Python\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Python\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
ImportError: DLL load failed: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Python\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'


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.
我的电脑在Windows 10上运行。安装的python版本是3.6.2

Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32

我还能做什么

在不知道安装了哪个版本的tf的情况下,如果您尚未从64位Windows二进制文件的uci存储库中获取tf,请尝试删除您的版本(pip卸载tensorflow),然后从下载并pip安装该版本。希望有帮助。

在anaconda中使用并安装tensorflow。如果您已经在使用anaconda,请使用
conda安装tensorflow

安装tesnorflow,我找到了一个简单的解决方案。虽然安装程序在另一台计算机上运行,但在这里我需要安装旧版本的tensorflow

pip install tensorflow==1.5

多亏了。

评论中的提示,您能澄清一下为什么使用这些“非官方”二进制文件会有所帮助吗?Tf及其许多依赖项要求在使用之前编译C、Fortran和Cython代码。来自“非官方”二进制文件网站的软件包是预编译的,并且被在windows上开发的Python社区广泛使用。我下载并安装了:
pip install tensorflow-1.7.0-cp36-cp36m-win_amd64。whl
不幸的是,我在导入tensorflow时仍然收到相同的错误消息。我只是注意到错误更短。现在只有两个“DLL加载失败”错误。以下是开头:
文件“C:\Users\Dan\AppData\Local\Programs\Python\36\lib\site packages\tensorflow\Python\pywrap\u tensorflow.py”,第58行,from tensorflow.Python.pywrap\u tensorflow\u internal import*
您能澄清为什么使用Anaconda会有帮助吗?我希望尽可能长时间地坚持官方支持的方式,这不是一种非官方的方式。anaconda是python发行版。由
conda
管理的软件包版本可以创建许多虚拟环境,每个环境都可以安装python软件包。为我工作!谢谢实际上,我首先使用命令
pip uninstall tensorflow
删除了1.7版本
pip install tensorflow==1.5