1.创建python虚拟环境,设置python=3.6.5,命名为test
C:\Users\luo>conda create --name test python=3.6.5
2.进入虚拟环境
activate test
3.从豆瓣源下载tensorflow,版本为1.15.0,cpu版本
pip install -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com tensorflow==1.15.0
这里有可能会出错,
这里暂时不知怎么解决,但是我首先
pip uninstall protobuf
卸载了protobuf之后,再次运行
pip install -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com tensorflow==1.15.0
这一次虽然也出现了报红wrapt,但最终显示似乎已经安装wrapt成功
第二次之后安装tensorflow成功了
4.之后进入python,使用tensorflow,查看版本
5.配置jupyter Notebook的内核
5.1首先安装ipykernel,还是使用的豆瓣源,使用默认源时出现超时错误,下载太慢了。
python -m pip install -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com ipykernel
5.2接下来添加jupyter Notebook的内核,这里name后面是命名的内核名字,这里我命名为test,与虚拟环境名字一致。
python -m ipykernel install --name test
5.3 查看jupyter Notebook的内核有哪些,使用如下命令列出内核。
jupyter kernelspec list
5.4 新建jupyter Notebook示例
import tensorflow as tf
hello = tf.constant('hello, Tensorflow!')
sess = tf.Session()
print(sess.run(hello))
输出如图所示: