一周未改动环境,导入TensorFlow时出现TypeError报错求助
解决TensorFlow导入时
TypeError: deprecated() got an unexpected keyword argument 'name'错误 问题场景
一周未使用环境且未修改配置,导入TensorFlow时触发上述错误,已尝试重装tensorflow-macos和tensorflow-metal,问题仍存在。
解决方案
执行以下步骤修复依赖版本冲突:
- 卸载当前
cryptography库:pip uninstall -y cryptography - 安装与TensorFlow兼容的版本(推荐38.0.4):
pip install cryptography==38.0.4 - 重新测试导入:
import tensorflow as tf
错误原因
该错误源于cryptography库版本与tensorflow-macos的依赖不匹配。新版本cryptography调整了deprecated()方法的参数列表,而TensorFlow内部代码仍使用包含name参数的旧调用方式,导致类型错误。
内容的提问来源于stack exchange,提问作者Jason Rich Darmawan
相关产品推荐
相关产品推荐

