Anaconda 安装 tensorflow 和 keras

说明:此操作是在 Anaconda Prompt 窗口完成的 CPU版 tensorflow 的安装。

1、用 conda 创建虚拟环境 tensorflow python=3.6

conda create -n tensorflow python=3.6
conda activate tensorflow    # 启用创建的环境

2、安装常用包

conda install numpy
conda install scipy
conda install pandas
conda install xlrd    # 使 pandas 读取 Excel 表格的包
conda install xlwt    # 使 pandas 写入 Excel 表格的包
conda install sklearn

3、安装 tensorflow

conda install tenserflow==1.5

4、安装 keras

cnda install keras==2.1.6

5、尝试导入 tensorflow

python    # 打开 python 解释器
import tensorflow as tf

不幸的是报错,如下

 5、ctrl + Z 退出 python,跟新 protobuf

conda install protobuf==3.6.0

6、打开 python 解释器,尝试重新导入

 如此应该是成功了吧!

按语:

据说 python、tensorflow 和 keras 有很强的版本对应关系,所以需特别注意。再次附加一片参考文章链接 https://www.cnblogs.com/carle-09/p/11661261.html

猜你喜欢

转载自www.cnblogs.com/shanger/p/12004971.html