python - 无法在 Windows 10 上的 python 3.7.6 上导入 tensorflow
问题描述
我最近卸载了 Anaconda 和 Python,因为我无意中卸载了 h5py。
但从那以后,一切似乎都停止了。
现在用 Python 3.7.6 重新安装 Anaconda 后,我尝试再次安装 TensorFlow,它已正确安装。
当我尝试导入它时发生了问题。错误如下:
~\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59
~\AppData\Roaming\Python\Python37\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
~\AppData\Roaming\Python\Python37\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)
241 else:
--> 242 return load_dynamic(name, filename, file)
243 elif type_ == PKG_DIRECTORY:
~\anaconda3\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: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-d6579f534729> in <module>
----> 1 import tensorflow
~\AppData\Roaming\Python\Python37\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
~\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\__init__.py in <module>
48 import numpy as np
49
---> 50 from tensorflow.python import pywrap_tensorflow
51
52 # Protocol buffers
~\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
67 for some common reasons and solutions. Include the entire stack trace
68 above this error message when asking for help.""" % 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 (most recent call last):
File "C:\Users\Jonat\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Jonat\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Jonat\AppData\Roaming\Python\Python37\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\Jonat\anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Jonat\anaconda3\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
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 更改为 2.0 尝试了几乎所有我看到的东西,但它仍然没有用。任何解决方案都非常感谢!
编辑:我尝试过的其他东西:-运行 pip install h5py
解决方案
固定的:
我通过以下方式将我的 tensorflow 降级到 2.0 版:
!pip install tensorflow==2.0
然后我还在以下链接上下载 x64: vc_redist.x64.exe:
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
推荐阅读
- c++ - 将一些参数绑定到模板模板参数的更简单语法
- ios - presentCodeRedemptionSheet 未显示兑换优惠按钮
- java - 将Java中的变量初始化为不同类的实例但相同的初始化关键字
- javascript - 是否可以自定义 JupyterLab 主菜单来路由另一个页面?
- reactjs - 未捕获的语法错误:在 ci 部署后导航到具有 2 个或更多路径元素的路由时出现意外标记“<”
- python - 什么是在 python 中渲染图像的抗锯齿?
- html - CSS - 两行布局中的最大宽度图像在受父级约束时应缩小
- python - 如何以与烧瓶中的 sqlite 相同的方式配置 mysql?
- arrays - 我正在尝试从二维数组中找到对角线的总和。但是得到它的地址而不是它的价值。谁能给我解释一下?
- javascript - 如何使用 querySelector 点击 svg?