安装TensorFlow 2.6.5后,执行import tensorflow时报错
2025/03/28
34
问题信息
问题来源 | 产品大类 | 产品子类 | 关键字 |
---|---|---|---|
官方 | 模型训练 | TensorFlow | TensorFlow2.6.5、import tensorflow、RuntimeError |
问题现象描述
安装TensorFlow 2.6.5后,执行import tensorflow时报错:“RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xd”。
可能原因
pip3安装TensorFlow的时候,可能会自动重装numpy,导致TensorFlow和numpy版本不兼容,需用户手动重装numpy。
解决措施
执行如下命令卸载旧版本numpy,安装TensorFlow 2.6.5适配的numpy 1.23.0版本。
pip3 uninstall numpy pip3 install numpy==1.23.0