尝试方法
1.删除原先tensorflow的版本
<<<pip3 uninstall tensorflow
2.重现安装最新版本
<<<pip3 install tensorflow2.6.0
但是仍在报错,无法运行!后来发现是tensorflow和keras版本之前不匹配的原因导致代码一直报错,即需要检查keras现在版本
<<<pip3 show keras
3.再重新更新keras版本
<<<pip3 install keras2.6
报错:cannot import name ‘dtensor‘ from ‘tensorflow.compat.v2.experimental‘ (/Users/pxs/anaconda3/lib
![](https://img-home.csdnimg.cn/images/20240711042549.png)