在 Python 3.8 中导入 tensorflow 时出错

Error when importing tensorflow in Python 3.8

我正在使用

当我 import tensorflow as tf 在 Python IDLE(安装时 Python 附带)时,它显示以下错误:

Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\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: 動態連結程式庫 (DLL) 初始化例行程序失敗。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python\Python__MyFinalProject__ML\TensorFlow.py", line 3, in <module>
    import tensorflow
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\__init__.py", line 39, in <module>
    from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python38\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: 動態連結程式庫 (DLL) 初始化例行程序失敗。


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

我尝试下载 VS 并将 C++ 包包含在 VS 安装程序中。但是还是解决不了这个问题:(

谁能帮忙

对不起,有些繁体字,我google翻译了:“动态链接程序库(DLL)初始化示例程序失败。”-->“动态link 库 (DLL) 初始化例程失败。"

编辑

刚刚想出一个解决方案:是我的 PC CPU 太旧以至于缺少 tensorflow 所需的某些 instructions(例如 AVX 支持)。

我试图找到类似 intel sde 的解决方法。但我想建议,不要在这上面浪费时间,更换新的 CPU 或购买新的 PC 即可。节省您的时间! :)

解决办法就是简单安装Microsoft Visual C++ 2015 Redistributable 64 bits. This way, the DLL is installed in system32 folder and the bug即可解决