Sometimes TensorFlow will seem to be installed correctly with pip only to fail when you try to import the package with the message:

Failed to load the native TensorFlow runtime.

There are a few common reasons for this error.

Built from source

Sometimes you see this error when TensorFlow is built from source incorrectly. You might be able to work around it by starting your Python interpreter in the folder you built from.

Otherwise, I recommend the following steps:

  1. Uninstall TensorFlow
  2. Re-install the pre-built package in a separate environment

Incompatible libraries

Other times, this error occurs because some library on your system doesn’t fit the TensorFlow requirements. A couple common culprits are:

Hardware requirements

You will also get this error if you use an older CPU that doesn’t support AVX instructions.

In this case, your options are basically to do one of the following:

  1. Use an older version of TensorFlow: pip install tensorflow<1.6 (this requires Python 3.6 or lower)
  2. Build TensorFlow from source without AVX instructions

Was this error caused by something else for you? Leave a comment below and I’ll try to help you work through it!