'TypeError: Unable to convert function return value to a Python type! The signature was () -> handle
I get an error when I import the TensorFlow. I tried to reinstall it but still, I keep getting this error---> TypeError: Unable to convert function return value to a Python type! The signature was () -> handle.
import tensorflow as tf
from tensorflow.keras.layers import Add, Input, Dense, Dropout
from tensorflow.keras.layers import BatchNormalization, Embedding
from tensorflow.keras.layers import Flatten, Concatenate
from tensorflow.keras import regularizers
from keras.regularizers import l1
from keras.regularizers import l2
from tensorflow.keras import regularizers
from keras.models import Sequential
from keras.wrappers.scikit_learn import KerasClassifier
Solution 1:[1]
For me, the first error that came from TensorFlow is
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
which suggests a NumPy version mismatch.
Therefore, downgrading NumPy to 1.21.6 should solve the problem:
pip install numpy==1.21.6
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 | M. Zhang |