【问题标题】:ImportError: No module named '_pywrap_tensorflow_internal' with Python 3.8ImportError:没有名为“_pywrap_tensorflow_internal”的模块与 Python 3.8
【发布时间】:2020-04-01 13:33:03
【问题描述】:

我在 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

【问题讨论】:

标签: python windows tensorflow visual-studio-code tensorflow2.0


【解决方案1】:

我在 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

请参考 CPUGPU 的 TF 测试构建配置详细信息。

如果您对 TF 版本没有任何顾虑,我建议您安装适用于 Windows 8 64 位系统的 TF 2。详情请参考here

注意: 安装 TF 2 后,如果您遇到任何 DLL 问题。可能的情况是

  1. 您需要安装 MSVC 2019
  2. 您的 CPU/Python 是 32 位的
  3. 您的 CPU 不支持 AVX2 指令
  4. 有一个库位于其他位置/未安装在您的系统上,无法加载。

【讨论】:

    猜你喜欢
    • 2017-10-20
    • 2020-04-21
    • 2020-05-04
    • 2021-09-28
    • 2018-02-02
    • 2013-01-06
    • 2015-12-09
    • 2012-01-26
    • 2020-12-15
    相关资源
    最近更新 更多