【发布时间】:2019-11-01 03:42:09
【问题描述】:
我已经为 tensorflow 创建了环境,但是当我导入时 张量流作为 tf 在 anaconda 提示符下,我猜它正在运行并显示:
(base) C:\Users\Administrator>activate env
(env) C:\Users\Administrator>python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2019-06-18 18:27:56.390819: I tensorflow/core/common_runtime/process_util.cc:71] Creating new thread pool with default inter op setting: 4. Tune using inter_op_parallelism_threads for best performance.
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
但是在我运行时在 spyder/Jupyter 中:
import tensorflow as tf
它向我显示错误:
n [2]: runfile('C:/Users/Administrator/.spyder-py3/temp.py', wdir='C:/Users/Administrator/.spyder-py3') Traceback(最近一次调用最后一次):
文件“”,第 1 行,在 runfile('C:/Users/Administrator/.spyder-py3/temp.py', wdir='C:/Users/Administrator/.spyder-py3')
文件“C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py”,第 786 行,在运行文件中 execfile(文件名,命名空间)
文件“C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py”,第 110 行,在 execfile exec(编译(f.read(),文件名,'exec'),命名空间)
文件“C:/Users/Administrator/.spyder-py3/temp.py”,第 1 行,在 将张量流导入为 tf
文件“C:\ProgramData\Anaconda3\lib\site-packages\tensorflow__init__.py”,第 24 行,在 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
文件“C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python__init__.py”,第 49 行,在 从 tensorflow.python 导入 pywrap_tensorflow
文件“C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”,第 74 行,在 引发 ImportError(msg)
ImportError: Traceback(最近一次调用最后一次): 文件“C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”,第 58 行,在 从 tensorflow.python.pywrap_tensorflow_internal 导入 * 文件“C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 28 行,在 _pywrap_tensorflow_internal = swig_import_helper() 文件“C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 24 行,在 swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, 路径名, 描述) 文件“C:\ProgramData\Anaconda3\lib\imp.py”,第 242 行,在 load_module return load_dynamic(名称,文件名,文件) 文件“C:\ProgramData\Anaconda3\lib\imp.py”,第 342 行,在 load_dynamic 返回_load(规格) ImportError: DLL load failed: 动态链接库 (DLL) 初始化例程失败。
无法加载原生 TensorFlow 运行时。
见https://www.tensorflow.org/install/errors
出于一些常见原因和解决方案。包括整个堆栈跟踪 寻求帮助时出现此错误消息。
我该如何继续。
【问题讨论】:
-
而且 spyder/Jupyter 也使用 Anaconda 提示符运行?
-
使用Spyder/Jupyter的时候,代码是在什么环境下运行的?您应该正确激活 env 并启动 Spyder 或使用 tensorflow 将 Spyder 安装到 env 或在 Spyder 设置中指定所需的 python 解释器。
-
配置 spyder 使用 env
-
现在我创建了一个环境并在其中安装了所有东西。现在一切都很好。非常感谢!
标签: python tensorflow jupyter-notebook anaconda spyder