No module named 'tensorflow.contrib'

控制台:pip install tensorflow

发现自己安装过,且版本2.4.1

搜索发现自己的python3.8版本无对应 tensorflow,故删除3.8版本,下载3.7版本【百度有教程】。

对应python3.7版本的tensorflow我下载的是1.14.0。其他应该也可,官网有对应表。

但是速度慢,毕竟使用pip下载。故换镜像下载:

修改为国内源:

新版ubuntu要求使用https源,要注意。

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/

豆瓣:http://pypi.douban.com/simple/

临时使用:

可以在使用pip的时候加参数 -i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==1.14.0,这样就会从清华这边的镜像去安装tensorflow库。

【注意!!!我看了csdn一个博主的:pip install tensorflow-gpu==1.14.0.好像是这个,反正tensorflow后面有gpu,把我搞惨了,因为我电脑根本没有支持的gpu,只能用cpu的(pip install tensorflow就是用cpu)】