'Error when "import tensorflow as tf" in colab

When I "import tensorflow as tf" in google colab I am getting the following error. Any idea how to fix it ?

RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-37-07e0f991eb97> in <module>()
----> 1 import tensorflow as tf
      2 

3 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/client/pywrap_tf_session.py in <module>()
     17 # pylint: disable=invalid-import-order,g-bad-import-order, wildcard-import, unused-import
     18 from tensorflow.python import pywrap_tensorflow
---> 19 from tensorflow.python.client._pywrap_tf_session import *
     20 from tensorflow.python.client._pywrap_tf_session import _TF_SetTarget
     21 from tensorflow.python.client._pywrap_tf_session import _TF_SetConfig

ImportError: SystemError: <built-in method __contains__ of dict object at 0x7f79368db0a0> returned a result with an error set

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------


Solution 1:[1]

This issue has been fixed now in 2.8.0 stable version. If it still persists ,please install Numpy 1.21.5 manually and Try again.

Solution 2:[2]

I've post a similar error on tensorflow github issue.

Tensorflow 2.8.0 | Error Message: ImportError: SystemError.

My solution (since I'm using conda environment on Windows 10), is to downgrade the Tensorflow version to 2.7.0. Hope help helps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tensorflow Support
Solution 2 aldy