參考鏈接:html
視頻教程:https://www.youtube.com/watch?v=mcIKDJYeyFYpython
如本文忽律細節,詳見https://github.com/jeffheaton/t81_558_deep_learning/blob/master/t81_558_class01_intro_python.ipynb (見Software Installation Part)git
Mac自帶python 2.7版本,須要下載最新版本python3.7github
1)下載miniconda: https://docs.conda.io/en/latest/miniconda.html, 選擇.pkg installer。下載完成後安裝,在Terminal 輸入Python 就會出現3.7版本bash
2)因爲寫這篇文章的時候,tensorflow還不支持python3.7, 爲了處理這種所以下載miniconda後,須要在conda中,爲TensorFLow建立一個Python3.6的環境。this
在Terminal 輸入 conda create --name tensorflow python=3.6 ,這樣就建立了一個名叫Tensorflow的環境。spa
TensorFlow環境的保存路徑是 environment location: /miniconda3/envs/tensorflow code
激活TensorFlow: 在Terminal輸入 source activate tensorflow (如下全部輸入的命令都是在激活的TensorFlow環境下執行的!而且this command must be done every time you open a new Anaconda/Miniconda terminal)視頻
active TensorFlow後,在Terminal輸入 conda install jupyter ,這樣Jupyter的保存路徑就是 environment location: /miniconda3/envs/tensorflow htm
Terminal 輸入: pip install --upgrade tensorflow==1.12.0
若是error:TensorFlow cannot be found. 緣由是:下載的Python3.7版本,因爲TensorFlow還不支持Python3.7,因此須要爲TensorFlow建立Python3.6環境,步驟見上文。
使用pip方式能夠安裝須要的其餘Package,好比:
conda install scipy pip install --upgrade sklearn pip install --upgrade pandas pip install --upgrade pandas-datareader pip install --upgrade matplotlib pip install --upgrade pillow pip install --upgrade requests pip install --upgrade h5py pip install --upgrade pyyaml pip install --upgrade psutil pip install --upgrade tensorflow==1.12.0 pip install --upgrade keras==2.2.4
驗證TensorFlow安裝成功:
Tenrminal 進入Python環境,輸入import tensorflow as tf ,沒有報錯就表明安裝成功。
You should also link your new tensorflow environment to Jupyter so that you can choose it as a Kernal. Always make sure to run your Jupyter notebooks from your 3.6 kernel.
在Terminal輸入: python -m ipykernel install --user --name tensorflow --display-name "Python 3.6 (tensorflow)"
Terminal回覆: Installed kernelspec tensorflow in /Users/Username/Library/Jupyter/Kernels/TensorFlow
安裝conda之後忽然間發現了一個問題,那就是Linux終端變樣了,在終端前部分出現了(base)字樣。緣由是aconda自動加入了命令到 .bashrc中, 在咱們打開終端的時候自動 執行了 conda activate base 命令,去掉base字樣,只須要在Terminal執行: conda deactivate
再次進入TensorFlow環境時,要先激活conda, conda activate