小白装tensorflow安装步骤

直接在python3.7环境下安装tensorflow,系统会报错。

 Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
1.查看自己的环境

conda --version

conda info --envs

windows10操作系统 conda 4.5.12,python3.7版本

1.右键使用 管理员权限 打开Anaconda Prompt

2.执行命令创建一个python3.5环境:conda create --name python35 python=3.5

3.当询问是否执行时,输入y(yes) 

4.激活此环境:

conda activate python35

退出此环境:

conda deactivate

5.安装tensorflow

以上就成功,如上提示有pip包可以升级,按照提示升级即可

6 测试是否安装成功

 >>>import os
>>> os.environ['TF_CPP_LOG_LEVEL']='2'
>>> sess=tf.Session()
>>> print(sess.run(hello))
b'hello,tensorflow'
>>> exit()

二、在jupyter notebook里面配置

1.激活tensorflow环境

conda activate python35

2.打开jupyter notebook文件夹路径

3.在环境中加入核

python -m ipykernel install --user --name python35 --display-name "Python (python35)"

可能会报错

点击安装conda install ipykernel 

然后执行python -m ipykernel install --user --name python35 --display-name "Python (python35)"

输入y

以上安装成功

打开jupyter notebook

进行测试

注意选择kernel为python35

import tensorflow as tf
hello=tf.constant("hello,tensorflow")
sess=tf.Session()
print(sess.run(hello))
sess.close()

不报错表示测试成功

猜你喜欢

转载自blog.csdn.net/qq_35016872/article/details/88530759