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.10.0

4、安裝 keras

cnda install keras==2.2.0

5、嘗試導入 tensorflow

python    # 打開 python 解釋器
import tensorflow as tf

不幸的是報錯,如下

 

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

conda install protobuf==3.6.0

6、打開 python 解釋器,嘗試重新導入

如此顯示,tensorflow 的導入應該是成功了!

keras 在導入時顯示的信息是因為用 conda 安裝的 cpu 版的 tensorflow。

 

按語:

據說 python、tensorflow 和 keras 有很強的版本對應關系,所以需特別注意。再次附加一片參考文章鏈接 https://www.cnblogs.com/carle-09/p/11661261.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM