python - 无法在 jupyter notebook 中导入 tensorflow
问题描述
每当尝试导入 tensorflow 等深度学习库时,keras 都会显示错误
import tensorflow
ImportError Traceback (most recent call last)
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
63 try:
---> 64 from tensorflow.python._pywrap_tensorflow_internal import *
65 # This try catch logic is because there is no bazel equivalent for py_extension.
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-3-370f0fe8bb94> in <module>
----> 1 import tensorflow
~\anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
39 import sys as _sys
40
---> 41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
43
~\anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
37 # go/tf-wildcard-import
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
---> 39 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
40
41 from tensorflow.python.eager import context
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
81 for some common reasons and solutions. Include the entire stack trace
82 above this error message when asking for help.""" % traceback.format_exc()
---> 83 raise ImportError(msg)
84
85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\Gokul\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
解决方案
在搜索您的问题时,我发现以下内容:
在我看来,卸载 tensorflow,如果你已经使用它pip
安装并使用conda
.
conda install -c anaconda tensorflow
修改为tensorflow-gpu
以防万一,在执行上述命令之前,请确保您已在conda
. 不要安装在底座上!
推荐阅读
- java - 前面的词=做什么?
- xslt - 无法使用“UTF-8”和“ISO-8859-1”显示字符“Œ œ Š š Ÿ † ‡ • ... ‰ € ™”
- jestjs - 如何在不抛出所有测试的情况下停止开玩笑描述
- python - 我如何测量算法在整个运行过程中所用的时间?
- reactjs - 如何修复未定义:属性错误 setTargetNode
- google-chrome - 自动捕获屏幕短片,包括 chrome devtools 窗口
- javascript - 我应该使用表单的提交事件还是使用ajax?
- javafx - 从另一个场景更新打开的场景
- c# - 如何使用 C# 创建带日期时间的文本文件名
- google-cloud-platform - 我正在寻找在 Google Data Studio 中绘制折线图(温度与时间戳)