【问题标题】:the following error pops up when i import tensorflow in jupyter当我在 jupyter 中导入 tensorflow 时弹出以下错误
【发布时间】:2020-07-18 09:48:59
【问题描述】:

ImportError Traceback (最近一次调用最后) ~\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in 57 ---> 58 from tensorflow.python.pywrap_tensorflow_internal import * 59

~\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in 27 return _mod ---> 28 _pywrap_tensorflow_internal = swig_import_helper() 29 del swig_import_helper

~\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py 在 swig_import_helper() 23 尝试:---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) 25 最后:

~\anaconda3\envs\py3-TF2.0\lib\imp.py in load_module(name, file, filename, details) 241 else: --> 242 return load_dynamic(name, filename, file) 243 elif type_ == PKG_DIRECTORY:

~\anaconda3\envs\py3-TF2.0\lib\imp.py in load_dynamic(name, path, file) 341 name=name, loader=loader, origin=path) --> 342 return _load(spec ) 343

ImportError: DLL load failed: 找不到指定的模块。

在处理上述异常的过程中,又发生了一个异常:

ImportError Traceback (最近一次调用最后一次) in ----> 1 import tensorflow as tf

~\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow_init_.py in 39 import sys as _sys 40 ---> 41 from tensorflow.python.tools import module_util as _module_util 42 from tensorflow。 python.util.lazy_loader 将 LazyLoader 导入为 _LazyLoader 43

~\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow\python_init_.py in 48 import numpy as np 49 ---> 50 from tensorflow.python import pywrap_tensorflow 51 52 # Protocol buffers

~\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py 67 中的一些常见原因和解决方法。寻求帮助时在此错误消息上方包含整个堆栈跟踪 68。""" % traceback.format_exc() ---> 69 raise ImportError(msg) 70 71 # pylint: enable=wildcard-import,g-import-not -at-top,unused-import,line-too-long

ImportError: Traceback(最近一次调用最后一次):文件“C:\Users\Abalreddy\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”,第 58 行,从 tensorflow.python.pywrap_tensorflow_internal 导入 * 文件“C:\Users\Abalreddy\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 28 行,在 _pywrap_tensorflow_internal = swig_import_helper () 文件“C:\Users\Abalreddy\anaconda3\envs\py3-TF2.0\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 24 行,在 swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal' , fp, 路径名, 描述) 文件 "C:\Users\Abalreddy\anaconda3\envs\py3-TF2.0\lib\imp.py", 第 242 行, 在 load_module 返回 load_dynamic(name, filename, file) 文件 "C :\Users\Abalreddy\anaconda3\envs\py3-TF2.0\lib\imp.py", line 342, in load_dynamic return _load(spec) ImportError: DLL load failed: The specified module could not be found.

无法加载原生 TensorFlow 运行时。

【问题讨论】:

  • 欢迎来到 SO。您能否为您的问题添加更多详细信息 - 您尝试过什么、目前正在使用什么以及您在研究时发现了什么?

标签: tensorflow anaconda jupyter


【解决方案1】:

要克服这个错误以便立即使用,只需创建一个新的conda environment with python 3.x 并安装必要的库。

为了将来使用,请检查您的python是否添加到路径变量中。

从这里安装 Visual Studio 2015-2019 x86 和 x64: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads (这在大多数情况下也有效)

【讨论】:

    【解决方案2】:

    尝试在 jupyter 本身中安装它。

    !pip install tensorflow

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-14
      • 2019-07-07
      相关资源
      最近更新 更多