为Python 3.6.0安装Tensorflow

时间:2018-10-01 19:27:29

标签: tensorflow

有人可以向我解释如何逐步安装Tensorflow for Python 3.7.0! (我正在使用ipython)! 我的系统是Windows 10 64位系统。 即使到目前为止我已经找到所有的解释,我也不知道该怎么办。 那么有人可以指出我要单击以安装张量流的确切链接吗? Tnx

ImportError                               Traceback (most recent call last)
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
     57 
---> 58   from tensorflow.python.pywrap_tensorflow_internal import *
     59   from tensorflow.python.pywrap_tensorflow_internal import __version__

~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>()
     27             return _mod
---> 28     _pywrap_tensorflow_internal = swig_import_helper()
     29     del swig_import_helper

~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
     23             try:
---> 24                 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
     25             finally:

~\Anaconda3\lib\imp.py in load_module(name, file, filename, details)
    242         else:
--> 243             return load_dynamic(name, filename, file)
    244     elif type_ == PKG_DIRECTORY:

~\Anaconda3\lib\imp.py in load_dynamic(name, path, file)
    342             name=name, loader=loader, origin=path)
--> 343         return _load(spec)
    344 

ImportError: DLL load failed: Een initialisatieroutine van de dynamic link library (DLL-bestand) is mislukt.

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-2-fae406f752e9> in <module>()
      6 from PIL import Image
      7 from scipy import ndimage
----> 8 import tensorflow as tf
      9 from tensorflow.python.framework import ops
     10 from cnn_utils import *

~\Anaconda3\lib\site-packages\tensorflow\__init__.py in <module>()
     20 
     21 # pylint: disable=g-bad-import-order
---> 22 from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
     23 
     24 try:

~\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>()
     47 import numpy as np
     48 
---> 49 from tensorflow.python import pywrap_tensorflow
     50 
     51 # Protocol buffers

~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
     72 for some common reasons and solutions.  Include the entire stack trace
     73 above this error message when asking for help.""" % traceback.format_exc()
---> 74   raise ImportError(msg)
     75 
     76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
  File "C:\Users\gstevens\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\gstevens\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\gstevens\Anaconda3\lib\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 "C:\Users\gstevens\Anaconda3\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\gstevens\Anaconda3\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: Een initialisatieroutine van de dynamic link library (DLL-bestand) is mislukt.


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.

2 个答案:

答案 0 :(得分:1)

总结official tensorflow installation guide中针对您的情况的安装步骤。

由于您已经在计算机上安装了Python 3.6和Conda(这很好!),我们可以继续确认其他内容。

1。 Microsoft Visual C ++ 2015可再发行更新3

安装 Microsoft Visual C ++ 2015可再发行组件更新3 。这是 Visual Studio 2015 附带的,但可以单独安装:

  1. 转到Visual Studio downloads
  2. 选择可再发行内容和构建工具,(它已经很好地隐藏了,请使用搜索来查找它)
  3. 下载并安装 Microsoft Visual C ++ 2015 Redistributable Update 3

Microsoft Visual C++ 2015 Redistributable Update 3

2。在您的Conda虚拟环境中安装Tensorflow

打开命令提示符。由于您已经创建了名称为tensorflow的环境,因此只需要:

  1. 如果要创建新环境,请运行conda create -n venv pip python=3.6。将venv替换为您选择的环境名称。
  2. source activate tensorflow。此行中的tensorflow是您运行conda create -n tensorflow python=3.6时命名的Conda环境的名称。除非您已按照步骤1进行操作并创建了新环境,否则请用在步骤1中使用的名称替换tensorflow
  3. 现在您已经激活了虚拟环境。在虚拟环境中,使用complete URL安装Tensorflow pip软件包,因此对于您而言,只需运行:

pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.11.0-cp36-cp36m-win_amd64.whl

如果以后再次安装,请根据URL列表更新上述命令中的URL。上面的命令最终将过时。

3。验证安装

重新启动命令提示符,然后再次激活conda环境,然后运行python -c "import tensorflow as tf; print(tf.__version__)",它将打印出您已安装的Tensorflow版本,在本例中为1.11.0。如果是这样,则说明您已经在您的Conda虚拟环境中成功安装了Tensorflow。恭喜!

如果它不起作用,请在此处评论,以便我修改答案以进一步为您提供帮助。

答案 1 :(得分:0)

Tensorflow尚不支持Python 3.7(https://github.com/tensorflow/tensorflow/issues/17022)。

使用Python 3.6。