TypeError:无法将函数返回值转换为Python类型!签名为()->handle

mbzjlibv  于 2023-04-10  发布在  Python
关注(0)|答案(3)|浏览(1388)

当我导入TensorFlow时,我得到一个错误。我试图重新安装它,但仍然,我一直得到这个错误---〉TypeError:无法将函数返回值转换为Python类型!签名为()-〉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
ryhaxcpt

ryhaxcpt1#

运行pip3 install numpy --upgrade为我解决了这个问题。

rqqzpn5f

rqqzpn5f2#

对我来说,来自TensorFlow的第一个错误是

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

这表明NumPy版本不匹配。
因此,将NumPy降级到1.21.6应该可以解决这个问题:

pip install numpy==1.21.6
kq0g1dla

kq0g1dla3#

除了将tensorflow-metal降级到v.0.6.0之外,没有任何帮助:

"pandas>=2.0.0",
"ipykernel>=6.22.0",
"tensorflow-macos>=2.10.0",
"tensorflow-metal==0.6.0",
"openpyxl>=3.1.2",
"plotly>=5.14.1",
"matplotlib>=3.7.1",
"scikit-learn>=1.2.2",
"keras>=2.10.0",
"keras-self-attention>=0.51.0",
"numpy~=1.24",

requires-python =“〉=3.9”

相关问题