1.安装tensorflow

pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple/

已经安装tensorflow后出现No module named 'tensorflow.contrib'

原因:tensorflow最新的默认2.*版本的,而contrib是1.*版本中有的

查看tf版本

$python
>>>import tensorflow as tf
>>>tf.__version__

卸载

pip uninstall tensorflow

2.指定版本:

pip install tensorflow==1.14.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/

指定版本后仍然报错

ERROR: No matching distribution found for tensorflow==1.14.0

原因:python版本的问题

在python=3.8以后,不支持1.*版本的

解决方式:装低版本的python

或者找contrib相应的替代库,对代码进行更改。

具体可以在tf2迁移进行查找

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐