python - ImportError: Python 3.8 没有名为“_pywrap_tensorflow_internal”的模块
问题描述
我在 Windows 8 上安装了 Python 3.8 和 TensorFlow 1.12,但是,在编写此代码时(注意我没有使用 Anaconda):
import tensorflow as tf
我收到以下错误:
Traceback (most recent call last):
File "C:\Users\Dany\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Users\Dany\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Dany\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Dany\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Dany\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
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.
File "C:\Users\Dany\Desktop\FYP\Python files\NN.py", line 1, in <module>
import tensorflow as tf
解决方案
我在 Windows 8 上安装了 Python 3.8 和 TensorFlow 1.12
这种组合不起作用。当 tensorflow(即 TF)为 1.12 版本时,不支持 Python 3.8。它仅支持时TF (2.2.0rc1,2.2.0rc2
)。请检查 pypi,对于1.12的 cp38 没有可用的文件。
如果您正在寻找兼容的 TF 1.12 的 python 版本是 3.5 到 3.7。如果您在安装时遇到任何问题,可能是编译器的原因,请安装MSVC 2015 update 3
。
请参阅 TF 测试的CPU和GPU构建配置详细信息。
如果您对 TF 版本没有任何顾虑,我建议您安装适用于 Windows 8 64 位系统的 TF 2。请参阅此处的更多详细信息。
注意:安装 TF 2 后,如果您遇到任何 DLL 问题。可能的情况是
- 您需要安装 MSVC 2019
- 你的 CPU/Python 是 32 位的
- 您的 CPU 不支持 AVX2 指令
- 有一个库位于不同的位置/未安装在您的系统上,无法加载。
推荐阅读
- php - Wamp PHP不会加载
- css - CSS3 - 在类和类上运行动画:悬停?
- ios - 我需要使用 iOS 人脸检测从实时视频中检测人脸,然后将每个人脸裁剪成一组人脸
- javascript - 将 Google Analytics 代码放入 JS 文件中
- excel - 使用 VBA 通过 RDP 连接到数据库
- google-apps-script - 将值设置为不同电子表格中的范围
- python - 如何在 TensorFlow 中执行稀疏矩阵 * 稀疏矩阵乘法?
- c++ - 将字符串逐个字符插入向量中
- javascript - 在包上安装特定组件(初学者)
- javascript - 正则表达式获取括号之间的文本