简体   繁体   中英

Error when importing tensorflow in Pyhton 3.8

I am using

  • Python 3.8.7
  • pip 20.2.3
  • Windows 10 64bit

and when I import tensorflow as tf on the Python IDLE, it shows the below error:

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

want to ask for the reason why it causes this error and solutions to solve this: )

And I'm sorry that there are some traditional chinese characters and I google translate it: "動態連結程式庫 (DLL) 初始化例行程序失敗。" --> "The dynamic link library (DLL) initialization routine failed."

The workaround is to simply install Microsoft Visual C++ 2015 Redistributable 64 bits . This way, the DLL is installed in system32 folder and the bug can be rectified.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM