Machine Learning with Python Project importing libraries base code giving error

[Neural Network SMS Text Classifier] projects base code that imports different libraries
[# import libraries
try:

%tensorflow_version only exists in Colab.

!pip install tf-nightly
except Exception:
pass
import tensorflow as tf
import pandas as pd
from tensorflow import keras
!pip install tensorflow-datasets
import tensorflow_datasets as tfds
import numpy as np
import matplotlib.pyplot as plt

print(tf.version)]

this code is giving out and error saying

[RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd

ImportError Traceback (most recent call last)
ImportError: numpy.core.multiarray failed to import

The above exception was the direct cause of the following exception:

SystemError Traceback (most recent call last)
SystemError: <built-in method contains of dict object at 0x7f976d6d7c80> returned a result with an error set

The above exception was the direct cause of the following exception:

ImportError Traceback (most recent call last)
in ()
5 except Exception:
6 pass
----> 7 import tensorflow as tf
8 import pandas as pd
9 from tensorflow import keras

3 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/client/pywrap_tf_session.py in ()
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: initialization failed]

i couldnt find a way to fix it , can someone help me?

Hi, someone had the same issue a week ago, I’ll link you to my solution:

1 Like