windows系统anaconda安装tensorflow 教程及心得

一些靠谱的教程:

  1. https://www.cnblogs.com/wwaann/articles/9978828.html
  2. https://www.bilibili.com/video/av50600192?from=search&seid=8043442974945099746

windows系统anaconda安装tensorflow时报错及解决办法:

报错 : Traceback (most recent call last):

或 : ERROR: tensorflow-1.1.0-cp35-cp35m-win_amd64.whl is not a supported wheel on this platform.

解决办法:
使用清华大学镜像安装,完美解决

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

若还不行可尝试换其他镜像

常用的国内镜像有:

阿里云 http://mirrors.aliyun.com/pypi/simple/
豆瓣http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
华中科技大学http://pypi.hustunique.com/

测试是否安装成功:

import tensorflow as tf
 print(tf.__version__)

输出版本号即安装成功.

若出现安装成功,但是在运行其它代码时发生错误,如:

AttributeError                     Traceback (most recent call last)
<ipython-input-1-94fb00151ac9> in <module>
      1 import tensorflow as tf
----> 2 sess = tf.Session()
      3 a = tf.constant(1)
      4 b = tf.constant(2)
      5 print(sess.run(a+b))

AttributeError: module 'tensorflow' has no attribute 'Session'

原因是因为tensorflow 2.0版本问题,把函数名称更改即可解决问题.

下面是 tensorflow1.x和tensorflow2.0两个版本的函数对比表,可自行下载查找
https://pan.baidu.com/s/1cWHtdQM1yoMOM4ZXt_vY9w,提取码:i953

发布了75 篇原创文章 · 获赞 1 · 访问量 2027

猜你喜欢

转载自blog.csdn.net/Rhao999/article/details/103944386