在Windows 10中使用非常规方法在Jupyter Notebook中导入Tensorflow

时间:2018-10-13 09:06:54

标签: python tensorflow jupyter dllimport

系统信息
操作系统平台和发行版(例如Linux Ubuntu 16.04):Windows 10 x64
从(源或二进制)安装TensorFlow:pip install tensorflow
TensorFlow版本(使用以下命令):1.11.0
Python版本:Python 3.6.6
Bazel版本(如果从源代码编译):n / a
GCC /编译器版本(如果从源代码编译):n / a
CUDA / cuDNN版本:不适用
GPU模型和内存:n / a
精确的再现命令:将tensorflow导入为tf

我遵循的步骤
1.在命令提示符(成功)中pip install tensorflow 2.在命令提示符(成功)中将tensorflow作为tf导入

然后我尝试了一下实验。从安装了所有tensorflow的所有包和模块的路径C:\ Users \ SnehaR \ AppData \ Local \ Programs \ Python \ Python36 \ Lib \ site-packages中,我将它们全部复制并粘贴到路径C:\ Users \ SnehaR \ Anaconda3 \ Lib \ site-packages。

  1. 使用Anaconda提示符打开jupyter笔记本。
  2. 尝试“将张量流导入为tf”。
    错误消息是

    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: Module use of python36.dll conflicts with this version of Python.
    
    During handling of the above exception, another exception occurred:
    
    ImportError                               Traceback (most recent call last)
    <ipython-input-1-64156d691fe5> in <module>()
    ----> 1 import tensorflow as tf
    
    ~\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\SnehaR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "C:\Users\SnehaR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "C:\Users\SnehaR\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\SnehaR\Anaconda3\lib\imp.py", line 243, in load_module
        return load_dynamic(name, filename, file)
      File "C:\Users\SnehaR\Anaconda3\lib\imp.py", line 343, in load_dynamic
        return _load(spec)
    ImportError: Module use of python36.dll conflicts with this version of Python.
    
    
    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.
    


有人尝试过这样做吗?
另外,为什么这种方法不起作用?

0 个答案:

没有答案