简体   繁体   中英

How to Fix "Failed to load the native TensorFlow runtime" Error

I'm trying to run I program I've written for Tensorflow from a file in Notepad using Powershell. Whenever I run python main.py to open and execute the code, I get the error below.

I haven't really found anything to try, and the only thing I felt I could do is uninstall and re-install Tensorflow, but that isn't working.

C:\Users\stxrsstillfade> cd tensorflow-demo
C:\Users\stxrsstillfade\tensorflow-demo> python main.py

The code error isn't even with the code. The traceback is saying that the problem is with the first line, import tensorflow .

Traceback (most recent call last):
  File "main.py", line 1, in <module>
    import tensorflow as tf
  File "C:\Python27\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Python27\lib\site-packages\tensorflow\python\__init__.py", line 72, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\tensorflow\python\__init__.py", line 66, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
    import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow


Failed to load the native TensorFlow runtime.

See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

I've tried getting to the GitHub link, but it seems to have been deleted.

Thank you for your answer in advance.

Please follow the instructions from TensorFlow website . I recommend please install Tensorflow 2 , if you are using lower versions.

To fix Failed to load the native TensorFlow runtime , you need to download and install/update the Microsoft Visual C++ 2015-2019 Redistributable (x64) from here .

If you are facing any other issues possible reasons are

  • Your CPU does not support AVX2 instructions
  • Your CPU/Python is on 32 bits
  • There is a library that is in a different location/not installed on your system that cannot be loaded.

Please refer tested build configurations for windows CPU and GPU .

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